Skip to content

Anitube [PT]: Fix quality label and video extractor#640

Open
WebDitto wants to merge 2 commits into
yuzono:masterfrom
WebDitto:fix/pt/anitube
Open

Anitube [PT]: Fix quality label and video extractor#640
WebDitto wants to merge 2 commits into
yuzono:masterfrom
WebDitto:fix/pt/anitube

Conversation

@WebDitto

@WebDitto WebDitto commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Closes #17

Checklist:

  • Updated extVersionCode value in build.gradle for individual extensions
  • Updated overrideVersionCode or baseVersionCode as needed for all multisrc extensions
  • Referenced all related issues in the PR body (e.g. "Closes #xyz")
  • Added the isNsfw = true flag in build.gradle when appropriate
  • Have not changed source names
  • Have explicitly kept the id if a source's name or language were changed
  • Have tested the modifications by compiling and running the extension through Android Studio
  • Have removed web_hi_res_512.png when adding a new extension
  • This PR is AI-assisted, I have reviewed the changes manually and confirmed they are not slop
  • Have made sure all the icons are in png format

Add 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:

  • Support resolution-based quality options (480p, 720p, 1080p) for Anitube PT videos with updated user preference keys.

Bug Fixes:

  • Fix incorrect or inconsistent quality labeling by aligning video qualities with their actual resolutions.
  • Improve video extraction robustness by handling failures per-link and avoiding crashes when a single extraction fails.
  • Prevent repeated network requests for shared ADS widget content by caching responses across concurrent extractions.

Enhancements:

  • Adjust video sorting to respect the new preferred quality setting and order videos by their numeric resolution.
  • Prefix video quality labels with the Anitube source name for clearer identification in multi-source contexts.

Build:

  • Bump the Anitube PT extension version code to 29.

@sourcery-ai

sourcery-ai Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Updates 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 caching

sequenceDiagram
    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))
Loading

File-Level Changes

Change Details Files
Switch to resolution-based quality labels and update preference handling and sorting logic.
  • Change hardcoded qualities from SD/HD/FHD to 480p/720p/1080p when mapping video links to qualities.
  • Update preferred quality preference key, default value, and entries to match the new resolution labels.
  • Rewrite the List
src/pt/anitube/src/eu/kanade/tachiyomi/animeextension/pt/anitube/Anitube.kt
Adjust video extraction flow to remove parallel helper usage and improve labeling and performance via caching.
  • Replace parallelCatchingFlatMapBlocking usage with a sequential flatMap that wraps extractor calls in runBlocking and runCatching, returning empty lists on failure.
  • Change constructed Video objects to use a prefixed quality label ("Anitube - ") to align with new sorting logic.
  • Introduce a ConcurrentHashMap-based cache for ads widget content keyed by URL, using getOrPut to avoid repeated network calls per host.
src/pt/anitube/src/eu/kanade/tachiyomi/animeextension/pt/anitube/Anitube.kt
src/pt/anitube/src/eu/kanade/tachiyomi/animeextension/pt/anitube/extractors/AnitubeExtractor.kt
Improve extractor behavior around ads URL resolution and video token usage.
  • Keep existing logic that resolves ADS_URL based on host but now reuses cached content for repeated calls.
  • Ensure final video URL concatenates the fetched token and uses the updated quality label format when constructing Video instances.
src/pt/anitube/src/eu/kanade/tachiyomi/animeextension/pt/anitube/extractors/AnitubeExtractor.kt
Bump the Anitube extension version code for release.
  • Increment extVersionCode from 28 to 29.
src/pt/anitube/build.gradle

Assessment against linked issues

Issue Objective Addressed Explanation
#17 Update the Anitube [PT] extension to use the new source URL/domain https://www.gashita.info (including any base URL or domain-related configuration). The PR only modifies video quality labels, video extraction logic, introduces a cache for ADS content, and bumps extVersionCode. The domain-related constants (e.g., PREF_DOMAIN_DEFAULT = "https://www.anitube.vip") and base URL usage remain unchanged, so the new domain https://www.gashita.info is not implemented.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue, and left some high level feedback:

  • 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.
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>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Anitube [PT]: New Domain

1 participant