fix external subtitle detection (#1679)
This commit is contained in:
@@ -31,6 +31,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||
- Update Plex show title in ETV when changed in Plex
|
||||
- Reindex seasons and episodes when show is updated from media server
|
||||
- This is needed to keep `show_*` tags accurate in the search index (e.g., `show_title`, `show_studio`)
|
||||
- Fix external subtitle detection to support forced/sdh subtitles with language tag before and after forced/sdh tag:
|
||||
- `Something.forced.en.srt`
|
||||
- `Something.sdh.en.srt`
|
||||
- `Something.en.forced.srt`
|
||||
- `Something.en.sdh.srt`
|
||||
|
||||
## [0.8.6-beta] - 2024-04-03
|
||||
### Added
|
||||
|
||||
@@ -80,7 +80,9 @@ public class LocalSubtitlesProviderTests
|
||||
new(@"/Movies/Avatar (2009)/Avatar (2009).mkv"),
|
||||
new(@"/Movies/Avatar (2009)/Avatar (2009).eng.srt"),
|
||||
new(@"/Movies/Avatar (2009)/Avatar (2009).en.forced.ass"),
|
||||
new(@"/Movies/Avatar (2009)/Avatar (2009).forced.en.ass"),
|
||||
new(@"/Movies/Avatar (2009)/Avatar (2009).en.sdh.srt"),
|
||||
new(@"/Movies/Avatar (2009)/Avatar (2009).sdh.en.srt"),
|
||||
new(@"/Movies/Avatar (2009)/Avatar (2009).de.srt"),
|
||||
new(@"/Movies/Avatar (2009)/Avatar (2009).de.sdh.forced.srt")
|
||||
};
|
||||
@@ -96,13 +98,13 @@ public class LocalSubtitlesProviderTests
|
||||
@"/Movies/Avatar (2009)/Avatar (2009).mkv",
|
||||
false);
|
||||
|
||||
result.Count.Should().Be(5);
|
||||
result.Count(s => s.Language == "eng").Should().Be(3);
|
||||
result.Count.Should().Be(7);
|
||||
result.Count(s => s.Language == "eng").Should().Be(5);
|
||||
result.Count(s => s.Language == "deu").Should().Be(2);
|
||||
result.Count(s => s.Forced).Should().Be(2);
|
||||
result.Count(s => s.SDH).Should().Be(2);
|
||||
result.Count(s => s.Codec == "subrip").Should().Be(4);
|
||||
result.Count(s => s.Codec == "ass").Should().Be(1);
|
||||
result.Count(s => s.Forced).Should().Be(3);
|
||||
result.Count(s => s.SDH).Should().Be(3);
|
||||
result.Count(s => s.Codec == "subrip").Should().Be(5);
|
||||
result.Count(s => s.Codec == "ass").Should().Be(2);
|
||||
result.Count(s => s.Path.Contains(@"/Movies/Avatar (2009)/")).Should().Be(0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,12 +128,30 @@ public class LocalSubtitlesProvider : ILocalSubtitlesProvider
|
||||
continue;
|
||||
}
|
||||
|
||||
bool forced = file.Contains(".forced.");
|
||||
bool sdh = file.Contains(".sdh.") || file.Contains(".cc.");
|
||||
string language = fileName;
|
||||
var forced = false;
|
||||
var sdh = false;
|
||||
|
||||
string language = fileName
|
||||
.Replace($"{withoutExtension}.", string.Empty)[..3]
|
||||
.Replace(".", string.Empty);
|
||||
if (file.Contains(".forced."))
|
||||
{
|
||||
forced = true;
|
||||
language = language.Replace(".forced", string.Empty);
|
||||
}
|
||||
|
||||
if (file.Contains(".sdh"))
|
||||
{
|
||||
sdh = true;
|
||||
language = language.Replace(".sdh", string.Empty);
|
||||
}
|
||||
|
||||
|
||||
if (file.Contains(".cc."))
|
||||
{
|
||||
sdh = true;
|
||||
language = language.Replace(".cc", string.Empty);
|
||||
}
|
||||
|
||||
language = language.Replace($"{withoutExtension}.", string.Empty)[..3].Replace(".", string.Empty);
|
||||
|
||||
Option<CultureInfo> maybeCulture = languageCodes.Find(
|
||||
ci => ci.TwoLetterISOLanguageName == language || ci.ThreeLetterISOLanguageName == language);
|
||||
|
||||
Reference in New Issue
Block a user