Add subdl unpack=1 support and fix anime season matching#3357
Merged
morpheus65535 merged 1 commit intoMay 30, 2026
Merged
Conversation
Two related improvements to the subdl provider: 1. Support subdl's new `unpack=1` API parameter. When a season pack is available, subdl now returns `unpack_files[]` with direct per-episode URLs. The provider sends `unpack=1` on all TV searches and, when a pack is detected for the target episode, uses the direct file URL instead of downloading the whole ZIP. A new `is_direct_file` flag on SubdlSubtitle tells `download_subtitle` to treat the response as a raw subtitle file rather than an archive. 2. Trust the season when an episode is matched via `absolute_episode`. Some anime uploads on subdl are tagged with `season=0` (or arc-based season numbering that differs from Sonarr's). With the existing logic, the season match failed and the subtitle was filtered out by Bazarr's series/episode gate even though the absolute episode uniquely identifies the (season, episode) pair. The fix adds `season` to matches whenever the episode was matched by absolute number.
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.
Summary
Two related improvements to the subdl provider:
1. Support subdl's new
unpack=1API parameterSubdl recently introduced an
unpack=1option that returns individual episode subtitle files (unpack_files[]) for season packs / multi-episode ZIPs, each with its own direct download URL.This PR sends
unpack=1on all TV subtitle searches and, when a pack is detected for the target episode, uses the direct per-episode URL instead of downloading the whole ZIP. This avoids the smart-extract step entirely and is significantly faster for episodes inside large season packs.Implementation details:
is_direct_fileflag onSubdlSubtitleto distinguish raw subtitle responses from ZIPs.query()adds('unpack', 1)to all four TV API calls (episode, absolute-episode, season-only, title-only). Movies excluded.unpack_files[]is searched for an entry matchingvideo.episode(orvideo.absolute_episode). On hit,download_linkis swapped to the unpack URL,is_packcleared, season/episode taken from the unpack entry, andfile_idmade unique with thefile_n_id.download_subtitle()handles the non-ZIP response by treatingr.contentas raw subtitle text via the already-importedfix_line_ending. Falls back to the old ZIP path unchanged whenunpack_filesis empty or no match.2. Trust the season when an episode is matched via
absolute_episodeSome anime uploads on subdl are tagged with
season=0(or arc-based season numbering that differs from Sonarr's). With the existing logic,seasonwasn't added to matches in that case, and Bazarr's series/episode gate then filtered the subtitle out — even though the absolute episode number uniquely identifies the (season, episode) pair.The fix adds
seasonto matches whenever the episode was matched by absolute number. Concrete example that motivated this: One Piece S23E01 (absolute episode 1156) — the [Erai-raws] subtitle (matching the user's release group exactly) was taggedseason=0, episode=1156on subdl and was being skipped.Test plan
unpack=1query returnsunpack_files[]from the live subdl APIdownload_subtitlecorrectly takes theis_direct_filebranch and produces valid subtitle content (verified with a real One Piece S02E01.assdownload — 88 KB, proper BOM +[Script Info]header)unpack_files(movies, older subdl entries) fall through to the existing ZIP behavior unchanged