Anitube [PT]: Fix quality label and video extractor#640
Open
WebDitto wants to merge 2 commits into
Open
Conversation
Contributor
Reviewer's GuideUpdates the Anitube PT extension to use resolution-based quality labels with a new preference key, adjusts video sorting accordingly, wraps the extractor in blocking calls instead of a parallel helper, adds caching for ad widget content in the extractor, and bumps the extension version code. Sequence diagram for AnitubeExtractor ads content cachingsequenceDiagram
participant Anitube
participant AnitubeExtractor
participant adsContentCache
participant OkHttpClient as client
participant AdsServer
Anitube->>AnitubeExtractor: getVideosFromUrl(playerInfo, quality)
AnitubeExtractor->>adsContentCache: getOrPut(adsUrl)
alt adsUrl not cached
adsContentCache-->>AnitubeExtractor: [miss]
AnitubeExtractor->>client: newCall(GET(adsUrl))
client-->>AnitubeExtractor: awaitSuccess().bodyString()
AnitubeExtractor-->>adsContentCache: store adsContent
else adsUrl cached
adsContentCache-->>AnitubeExtractor: adsContent
end
AnitubeExtractor-->>Anitube: listOf(Video(finalUrl, "Anitube - " + quality, finalUrl, headers))
File-Level Changes
Assessment against linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- Replacing
parallelCatchingFlatMapBlockingwithrunBlockinginside a plainflatMapremoves parallelism and can block the calling thread; consider using coroutine-based concurrency (e.g., suspending functions with structured concurrency) instead ofrunBlockingin the mapping. - The new sorting logic relies on the
qualitystring starting with"Anitube - "and ending with ap-suffix; it would be more robust to store resolution and label in separate fields or to parse defensively to avoid breakage if the label format changes. - Changing the preference key from
preferred_qualitytopreferred_quality_newwill reset users’ existing quality preference; if that’s not intended, consider migrating or reusing the old key while handling the new resolution-based values.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Replacing `parallelCatchingFlatMapBlocking` with `runBlocking` inside a plain `flatMap` removes parallelism and can block the calling thread; consider using coroutine-based concurrency (e.g., suspending functions with structured concurrency) instead of `runBlocking` in the mapping.
- The new sorting logic relies on the `quality` string starting with `"Anitube - "` and ending with a `p`-suffix; it would be more robust to store resolution and label in separate fields or to parse defensively to avoid breakage if the label format changes.
- Changing the preference key from `preferred_quality` to `preferred_quality_new` will reset users’ existing quality preference; if that’s not intended, consider migrating or reusing the old key while handling the new resolution-based values.
## Individual Comments
### Comment 1
<location path="src/pt/anitube/src/eu/kanade/tachiyomi/animeextension/pt/anitube/extractors/AnitubeExtractor.kt" line_range="25-30" />
<code_context>
private val tag by lazy { javaClass.simpleName }
+ // Cache for the host-wide ADS widget content, shared across concurrent calls.
+ private val adsContentCache = ConcurrentHashMap<String, String>()
+
</code_context>
<issue_to_address>
**issue (bug_risk):** Using getOrPut with ConcurrentHashMap is not atomic and can cause duplicate network calls under concurrency.
Kotlin’s getOrPut is not atomic on ConcurrentHashMap, so multiple threads can see a missing key and each trigger the lambda, leading to duplicate GETs for the same adsUrl. To ensure only one request per adsUrl, use computeIfAbsent on the ConcurrentHashMap or add synchronization around populating the cache for each key.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #17
Checklist:
extVersionCodevalue inbuild.gradlefor individual extensionsoverrideVersionCodeorbaseVersionCodeas needed for all multisrc extensionsisNsfw = trueflag inbuild.gradlewhen appropriateidif a source's name or language were changedweb_hi_res_512.pngwhen adding a new extensionAdd a 👍 reaction to pull requests you find important.
Summary by Sourcery
Update the Anitube PT extension to use resolution-based quality labels and improve video extraction reliability and performance.
New Features:
Bug Fixes:
Enhancements:
Build: