Skip to content

Animelib [RU]: Fix episode naming for movies#631

Open
RikCost wants to merge 3 commits into
yuzono:masterfrom
RikCost:animelib-seriesname
Open

Animelib [RU]: Fix episode naming for movies#631
RikCost wants to merge 3 commits into
yuzono:masterfrom
RikCost:animelib-seriesname

Conversation

@RikCost

@RikCost RikCost commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

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

Fix episode naming for Animelib movies and update extension metadata.

New Features:

  • Display movie-type anime entries as a single "Film" episode instead of a season/episode pair.

Bug Fixes:

  • Correct episode title formatting for single-episode movies by detecting anime type from the API.

Enhancements:

  • Refine episode list retrieval to support movie-aware naming using additional anime metadata.

Build:

  • Bump Animelib extension version code to 16.

@sourcery-ai

sourcery-ai Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Adjusts Animelib episode parsing to treat single-episode movies as films instead of season/episode entries, by fetching anime details to detect movie type and propagating a movie flag into episode naming, while adding DTO support for anime type metadata and bumping the extension version code.

Sequence diagram for Animelib getEpisodeList movie handling

sequenceDiagram
    participant Animelib
    participant Client
    participant EpisodeApi as episodeListRequest
    participant AnimeApi as animeDetailsRequest

    Animelib->>EpisodeApi: episodeListRequest(anime)
    EpisodeApi-->>Animelib: Request
    Animelib->>Client: newCall(Request)
    Client-->>Animelib: awaitSuccess()
    Animelib->>Animelib: parseAs EpisodeList
    Animelib->>Animelib: episodes = EpisodeList.data

    alt [episodes.size == 1]
        Animelib->>AnimeApi: animeDetailsRequest(anime)
        AnimeApi-->>Animelib: Request
        Animelib->>Client: newCall(Request)
        Client-->>Animelib: awaitSuccess()
        Animelib->>Animelib: parseAs AnimeInfo
        Animelib->>Animelib: isMovie = AnimeInfo.data.type.id == 17
    else [episodes.size != 1]
        Animelib->>Animelib: isMovie = false
    end

    Animelib->>Animelib: episodes.map { toSEpisode(isMovie) }.reversed()
    Animelib-->>Animelib: List<SEpisode>
Loading

File-Level Changes

Change Details Files
Refactor episode list parsing and add movie-specific episode handling.
  • Simplified episodeListParse implementation into a single-expression function that parses the response and maps DTOs to SEpisode objects in reverse order.
  • Introduced a suspend getEpisodeList override that fetches episodes, calls animeDetailsRequest, and determines whether the anime is a movie based on type id and single-episode size.
  • Used runCatching with a safe default to avoid failures if the type lookup or parsing fails, and passed the computed isMovie flag into episode conversion.
src/ru/animelib/src/eu/kanade/tachiyomi/animeextension/ru/animelib/Animelib.kt
Update episode DTO-to-domain mapping to support movie-specific naming.
  • Extended EpisodeInfo.toSEpisode to accept an isMovie flag, defaulting to false.
  • Changed episode name generation to use a "Фильм" prefix (with optional episodeName) for movies and retain the original "Сезон {season} Серия {number} {episodeName}" format for non-movie entries.
  • Kept URL, episode_number parsing, and date_upload handling unchanged.
src/ru/animelib/src/eu/kanade/tachiyomi/animeextension/ru/animelib/Animelib.kt
Add anime type metadata to DTOs to enable movie detection.
  • Introduced a new AnimeType serializable DTO with id and optional label fields.
  • Added an optional type field of type AnimeType to AnimeData, mapped via Kotlinx Serialization.
src/ru/animelib/src/eu/kanade/tachiyomi/animeextension/ru/animelib/AnimelibDto.kt
Bump Animelib extension version code for the changes.
  • Incremented extVersionCode from 15 to 16 in the Animelib build.gradle configuration.
src/ru/animelib/build.gradle

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:

  • Consider avoiding the extra network call in getEpisodeList by reusing already-fetched anime metadata (or caching the result) when determining whether an entry is a movie, to reduce latency and load on the API.
  • The movie type check type?.id == 17 introduces a magic number; consider extracting this ID into a named constant or using a more self-descriptive condition (e.g., via label) to make the logic clearer and less brittle.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider avoiding the extra network call in `getEpisodeList` by reusing already-fetched anime metadata (or caching the result) when determining whether an entry is a movie, to reduce latency and load on the API.
- The movie type check `type?.id == 17` introduces a magic number; consider extracting this ID into a named constant or using a more self-descriptive condition (e.g., via `label`) to make the logic clearer and less brittle.

## Individual Comments

### Comment 1
<location path="src/ru/animelib/src/eu/kanade/tachiyomi/animeextension/ru/animelib/Animelib.kt" line_range="251" />
<code_context>
+        // Полнометражки (тип «Фильм») показываем как «Фильм», а не «Сезон 1 Серия 1»
+        val isMovie = episodes.size == 1 && runCatching {
+            client.newCall(animeDetailsRequest(anime)).awaitSuccess()
+                .parseAs<AnimeInfo>().data.type?.id == 17
+        }.getOrDefault(false)
+
</code_context>
<issue_to_address>
**suggestion:** Replace the hardcoded `type.id == 17` with a named constant or enum for better readability.

Using `17` directly obscures what this type represents and hard-codes a backend-specific id into the client. Please introduce a named constant or enum-backed mapping so the meaning is explicit and changes in API ids don’t cause unnoticed regressions.

Suggested implementation:

```
        // Полнометражки (тип «Фильм») показываем как «Фильм», а не «Сезон 1 Серия 1»
        val isMovie = episodes.size == 1 && runCatching {
            client.newCall(animeDetailsRequest(anime)).awaitSuccess()
                .parseAs<AnimeInfo>().data.type?.id == MOVIE_TYPE_ID
        }.getOrDefault(false)

```

To fully implement the suggestion:
1. Introduce a named constant for the movie type id near the top of `Animelib.kt`, outside the class or in a companion object, for example:
   `private const val MOVIE_TYPE_ID = 17`
2. Optionally add a short comment documenting that this value corresponds to the backend "Фильм" type from the API schema.
</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.

1 participant