Animelib [RU]: Fix episode naming for movies#631
Open
RikCost wants to merge 3 commits into
Open
Conversation
Refactor episode parsing methods to simplify code and handle movie episodes correctly.
Contributor
Reviewer's GuideAdjusts 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 handlingsequenceDiagram
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>
File-Level Changes
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:
- Consider avoiding the extra network call in
getEpisodeListby 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 == 17introduces a magic number; consider extracting this ID into a named constant or using a more self-descriptive condition (e.g., vialabel) 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>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.
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
Fix episode naming for Animelib movies and update extension metadata.
New Features:
Bug Fixes:
Enhancements:
Build: