Radarr icon indicating copy to clipboard operation
Radarr copied to clipboard

Subtitle sidecars lose their language on rename: ".en.hi" is parsed as Hindi and ".pt-BR" as language "pt" + title "BR"

Open Shyrka973 opened this issue 1 month ago • 2 comments

Is there an existing issue for this?

  • [x] I have searched the existing open and closed issues

(Related: #11031 — closed with a request to file a bug report with trace logs; #5268 / #5191 / #4267 for pt-BR.)

Current Behavior

When Radarr renames a movie, existing subtitle sidecars that use two very common naming conventions lose their language:

  1. Hearing-impaired tag hi (written by Bazarr and many tools as <name>.<lang>.hi.srt). hi is not in the tag list of SubtitleLanguageRegex (LanguageParser.cs#L60: forced|foreign|default|cc|psdh|sdh), so it is parsed as the ISO code of Hindi (IsoLanguages.cs#L37). All such files then fall into the same "Hindi" group and are numbered by GetSuffix (SubtitleService.cs#L238). The real language (en, es, pt-BR) is gone.
  2. Language with region (<name>.pt-BR.srt, BCP 47). iso_code is [a-z]{2,3}, so pt-BR is never captured as one code; SubtitleLanguageTitleRegex (L62) reads it as language pt + title BR, and the file is renamed <name>.BR.pt.srt — which Plex and other tools then read as Breton (br).

Note that IsoLanguages.Find() already resolves pt-br to Portuguese (Brazil) (IsoLanguages.cs#L77, entry at L41) — it is only the regexes that never hand it a region code, and GetSuffix only ever writes TwoLetterCode (L262), so the region would be dropped on rename anyway.

In my library this produced 1,600+ <name>.<n>.hi.srt files and 2,100+ <name>.BR.pt.srt files after two mass renames triggered by a naming-format change. Bazarr no longer finds its own files and downloads them again, creating byte-identical duplicates.

Expected Behavior

  • hi following a language code is kept as a hearing-impaired tag (like sdh/cc): Movie.en.hi.srt → Movie (2006) [Bluray-1080p].en.hi.srt. A bare Movie.hi.srt can stay Hindi.
  • xx-YY is parsed as language + region and written back with its region: Movie.pt-BR.srt → Movie (2006) [Bluray-1080p].pt-BR.srt.

Steps To Reproduce

  1. Movie folder containing:
    Movie (2006).mkv
    Movie (2006).en.hi.srt
    Movie (2006).es.hi.srt
    Movie (2006).pt-BR.hi.srt
    Movie (2006).pt-BR.srt
    
  2. Refresh & Scan, then change the movie naming format (or use Organize/Rename) so the movie file is renamed.
  3. Result:
    Movie (2006) [Bluray-1080p].1.hi.srt
    Movie (2006) [Bluray-1080p].2.hi.srt
    Movie (2006) [Bluray-1080p].3.hi.srt
    Movie (2006) [Bluray-1080p].BR.pt.srt
    

Environment

  • OS: Unraid (Docker)
  • Radarr: 6.4.4.10685
  • Docker Install: Yes (binhex/arch-radarr)
  • Using Reverse Proxy: Yes
  • Browser: n/a
  • Database: SQLite

What branch are you running?

master

Trace Logs? Not Optional

Trace logs (Log Level = Trace, one movie: Refresh & Scan, then Rename of that single movie file): https://gist.github.com/Shyrka973/3b4bbb345b0816e14cd507712e259691

Observed on that movie (file stem shortened to X):

before rename                after rename
X.en.hi.srt        ->        X.9.hi.srt      (logged as "Hindi.srt")
X.pt-BR.hi.srt     ->        X.7.hi.srt      (logged as "Hindi.srt")
X.pt-BR.sdh.srt    ->        X.BR.pt.sdh.srt (logged as "Portuguese.BR.sdh.srt")
X.es.srt           ->        X.es.srt
X.fr.sdh.srt       ->        X.fr.sdh.srt

Note: importExtraFiles is disabled; the sidecars are picked up by ExistingSubtitleImporter during the scan and renamed with the movie file anyway.

Suggested fix: add hi to the tag alternatives of SubtitleLanguageRegex / SubtitleLanguageTitleRegex (it only applies after a language code, so Movie.hi.srt still resolves to Hindi); allow an optional -[a-z]{2} region in iso_code; and have GetSuffix append -<CountryCode> when the IsoLanguage has one. A quick test of the proposed pattern on .en.hi, .es.hi, .pt-BR.hi, .pt-BR, .hi, .en.sdh, .en.forced, .fr gives the expected language/tag for each, with no change for the cases that work today.

  • [x] I have read and followed the steps in the wiki link above and provided the required trace logs - the logs contain trace - that are relevant and show this issue.

Shyrka973 avatar Oct 11 '26 23:10 Shyrka973

:wave: @Shyrka973, this issue was closed automatically because it was created without following an issue template. Please update the issue following the correct template for this issue. Once updated please reply to this issue so we can review and re-open. In the future, use the issue templates instead of creating your own.

github-actions[bot] avatar Oct 11 '26 23:10 github-actions[bot]

Hi, this issue was created with the GitHub CLI, which doesn't go through the issue form, so the template labels were never applied, and I can't add labels myself as an outside contributor.

The content already follows every section of the bug report form: existing issue search, current and expected behavior, steps to reproduce, environment, branch, and Trace logs (gist linked in the "Trace Logs" section). Could a maintainer please reopen it and apply Type: Bug / Status: Needs Triage?

Thanks!

Shyrka973 avatar Oct 18 '26 11:10 Shyrka973