Skip to content

fix(crunchy): use relative episode numbers for filename generation#1219

Open
xNabil wants to merge 1 commit intoanidl:masterfrom
xNabil:master
Open

fix(crunchy): use relative episode numbers for filename generation#1219
xNabil wants to merge 1 commit intoanidl:masterfrom
xNabil:master

Conversation

@xNabil
Copy link

@xNabil xNabil commented Mar 8, 2026

PR Description

When fetching a specific season of a show that uses continuous/absolute numbering on Crunchyroll's backend (such as Jujutsu Kaisen), the aniDL CLI correctly calculates and displays the relative episode numbers (E1, E2, E3...) in the terminal.

However, when the download is initiated, the {episode} variable in the filename template pulls directly from item.episode (the raw API absolute number). This causes a mismatch where the user selects episode 9 from the CLI list, but the resulting file is saved as episode 56, breaking local media library management (like Plex or Jellyfin).

The Solution
In the itemSelectMultiDub function, the episodeNumber property mapped into the epMeta payload was hardcoded to item.episode.

This PR updates that mapping to use the pre-calculated epNum variable instead. Since epNum already handles the --absolute flag logic right above it, this ensures the filename strictly respects the user's configuration and matches the terminal output.

Example / Before & After
Testing with Jujutsu Kaisen Season 3:
aniDL --service crunchy -srz GRDV0019R -s GS00365546JAJP --episode 09

Output:

  • Before this PR: The resulting file is named JUJUTSU KAISEN - S03E56 [1080p].mkv
  • After this PR: The resulting file is named JUJUTSU KAISEN - S03E09 [1080p].mkv

Checklist:

  • Tested the change locally.
  • Verified that the --absolute flag still functions correctly if a user wants the continuous numbering.

When downloading from Crunchyroll using season-specific arguments (e.g., `-s`), the CLI correctly displayed the relative episode number (e.g., E9), but the actual downloaded file used Crunchyroll's absolute API numbering (e.g., E56). 

This commit updates the `itemSelectMultiDub` payload mapping to use the calculated `epNum` variable instead of the raw `item.episode` data. 

* Fixes an issue where multi-season shows had continuous absolute numbering in output filenames.
* Ensures the `{episode}` template variable correctly matches the relative episode number shown in the CLI terminal output.
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