Skip to content

Add subdl unpack=1 support and fix anime season matching#3357

Merged
morpheus65535 merged 1 commit into
morpheus65535:developmentfrom
mi3lix9:subdl-unpack-and-anime-season-fix
May 30, 2026
Merged

Add subdl unpack=1 support and fix anime season matching#3357
morpheus65535 merged 1 commit into
morpheus65535:developmentfrom
mi3lix9:subdl-unpack-and-anime-season-fix

Conversation

@mi3lix9
Copy link
Copy Markdown

@mi3lix9 mi3lix9 commented May 28, 2026

Summary

Two related improvements to the subdl provider:

1. Support subdl's new unpack=1 API parameter

Subdl recently introduced an unpack=1 option 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=1 on 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:

  • New is_direct_file flag on SubdlSubtitle to 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.
  • After pack detection, the item's unpack_files[] is searched for an entry matching video.episode (or video.absolute_episode). On hit, download_link is swapped to the unpack URL, is_pack cleared, season/episode taken from the unpack entry, and file_id made unique with the file_n_id.
  • download_subtitle() handles the non-ZIP response by treating r.content as raw subtitle text via the already-imported fix_line_ending. Falls back to the old ZIP path unchanged when unpack_files is empty or no match.

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, season wasn'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 season to 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 tagged season=0, episode=1156 on subdl and was being skipped.

Test plan

  • unpack=1 query returns unpack_files[] from the live subdl API
  • Provider end-to-end: pack item is detected, unpack entry matched by episode, direct URL stored, ZIP path skipped
  • download_subtitle correctly takes the is_direct_file branch and produces valid subtitle content (verified with a real One Piece S02E01 .ass download — 88 KB, proper BOM + [Script Info] header)
  • Backward compatibility: items without unpack_files (movies, older subdl entries) fall through to the existing ZIP behavior unchanged
  • Season-via-absolute-episode fix: the previously-skipped [Erai-raws] One Piece 1156 subtitle now scores correctly and is selectable in the UI

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.
@mi3lix9 mi3lix9 marked this pull request as ready for review May 28, 2026 16:06
@morpheus65535 morpheus65535 merged commit 589fbce into morpheus65535:development May 30, 2026
5 checks passed
@mi3lix9 mi3lix9 deleted the subdl-unpack-and-anime-season-fix branch May 30, 2026 18:56
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.

2 participants