Skip to content

Fixed: Scene title replacement eating codec tokens from simpleReleaseTitle - #327

Merged
plz12345 merged 1 commit into
eros-developfrom
fix/scene-title-replacement-eats-codec-tokens
Jul 16, 2026
Merged

Fixed: Scene title replacement eating codec tokens from simpleReleaseTitle#327
plz12345 merged 1 commit into
eros-developfrom
fix/scene-title-replacement-eats-codec-tokens

Conversation

@plz12345

Copy link
Copy Markdown
Contributor

Database Migration

NO

Description

Release Title custom formats matching on codec tokens (x265/HEVC, x264, ...) silently failed to score on scene releases, seemingly at random.

ParseMovieTitle matches the report regexes against simpleTitle, which has already had the quality and codec tokens deleted by SimpleTitleRegex. It then applies the title replacement to simpleReleaseTitle, which keeps them. The two strings don't address the same characters, so the replacement span overran the title and cut into the quality block, leaving exactly as many trailing characters as SimpleTitleRegex had deleted:

Stripped Chars Surviving tail
x265 4 ROUP
1080p 5 GROUP
1080p + x265 9 265-GROUP

So x265 became 265, the codec token no longer existed in the string the custom format is evaluated against, and the CF couldn't match. Whether the codec survived was pure arithmetic coincidence — the issue's "working" example only worked because the 9 surviving characters happened to be .x265.PRT. The apostrophe correlation reported in the issue is a red herring; titles with no punctuation at all reproduce it just as reliably.

This block came from Radarr, where the title capture is bounded by the year and so never crosses the stripped region. Whisparr's scene regexes capture the title through to the end of the string, so the capture spans the quality block as well — meaning simply realigning the offsets would drop the codec entirely rather than partially.

Fixed by replacing ReleaseTokens by value instead of splicing on the stale offsets. ReleaseTokens is cut from releaseTitle at the title boundary, so the quality block survives for custom formats to match against:

Studio.26.07.09.Performer.Its.Great.In.The.Sample.XXX.1080p.x265-GROUP
  before: Studio.26.07.09.Performer.Its.A.Movie265-GROUP
  after:  Studio.26.07.09.A.Movie.XXX.1080p.x265-GROUP

Movie parsing is unaffected — the movie branch never sets ReleaseTokens and falls through to the existing path.

Verified against the issue's repro through /api/v3/parse with the reporter's exact custom format regex, which now matches. Also removes the // TODO: Add tests for this! that sat above this block.

Known remaining gap, pre-existing and not a regression: SpecialEpisodeTitleRegex bounds on resolutions and WEB/HDTV but not codec tokens, so a release carrying a codec but no resolution (Studio.26.07.09.Performer.Title.XXX.x265-GROUP) still loses it. Those releases already parse as quality Unknown. Worth a follow-up rather than widening this change, since that regex also drives title matching.

Screenshot(s) (if UI related)

N/A — not UI related.

Todos

  • Tests
  • Translation Keys (./src/NzbDrone.Core/Localization/Core/en.json) — n/a, no user-facing strings

Issues Fixed or Closed by this PR

…Title

The title capture is matched against simpleTitle, which has already had the
quality and codec tokens deleted, but the replacement is applied to
simpleReleaseTitle, which keeps them. The two strings do not address the same
characters, so the replacement span overran the title and cut into the quality
block, leaving exactly as many trailing characters as SimpleTitleRegex had
deleted -- x265 became 265. Release Title custom formats matching on codec
tokens then silently failed to score, seemingly at random.

Scene regexes capture the title through to the end of the string, so the
capture spans the quality block as well and bounding it by the capture alone
would drop the codec entirely. Replace ReleaseTokens by value instead: it is
cut from releaseTitle at the title boundary, so the quality block survives for
custom formats to match against.

Fixes Whisparr/Whisparr#1111
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@plz12345
plz12345 merged commit 154f63d into eros-develop Jul 16, 2026
38 checks passed
@plz12345
plz12345 deleted the fix/scene-title-replacement-eats-codec-tokens branch July 16, 2026 08:27
@plz12345
plz12345 restored the fix/scene-title-replacement-eats-codec-tokens branch July 16, 2026 08:27
@plz12345
plz12345 deleted the fix/scene-title-replacement-eats-codec-tokens branch July 16, 2026 08:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

3 participants