Guard against multiple language codes

This commit is contained in:
Jendrik Weise 2023-09-02 04:22:18 +02:00
parent 1ffcc92dc6
commit f25d44b3be
2 changed files with 4 additions and 3 deletions

View File

@ -464,6 +464,7 @@ namespace NzbDrone.Core.Test.ParserTests
[TestCase("Name (2020) - S01E20 - [AAC 2.0].default.ass", "Name (2020)/Season 1/Name (2020) - S01E20 - [AAC 2.0].mkv")]
[TestCase("Name (2020) - S01E20 - [AAC 2.0].ass", "Name (2020)/Season 1/Name (2020) - S01E20 - [AAC 2.0].mkv")]
[TestCase("Name (2020) - S01E20 - [AAC 2.0].testtitle.ass", "Name (2020)/Season 1/Name (2020) - S01E20 - [AAC 2.0].mkv")]
[TestCase("Name (2020) - S01E20 - [AAC 2.0].testtitle.eng.fra.ass", "Name (2020)/Season 1/Name (2020) - S01E20 - [AAC 2.0].mkv")]
public void should_not_parse_false_title(string postTitle, string episodeFilePath)
{
var episode = new Episode

View File

@ -259,9 +259,9 @@ namespace NzbDrone.Core.Parser
var simpleFilename = Path.GetFileNameWithoutExtension(fileName);
var matchTitle = SubtitleLanguageTitleRegex.Match(simpleFilename);
if (matchTitle.Groups["iso_code"].Captures.Count != 1)
if (matchTitle.Groups["iso_code"].Captures.Count is var languageCodeNumber && languageCodeNumber != 1)
{
throw new LanguageParsingException("Subtitle file title probably parsed incorrectly, no language code found, not using.");
throw new LanguageParsingException(string.Format("Subtitle file title probably parsed incorrectly, {0} language codes found, not using.", languageCodeNumber));
}
var isoCode = matchTitle.Groups["iso_code"].Value;
@ -274,7 +274,7 @@ namespace NzbDrone.Core.Parser
.Cast<Capture>()
.Where(tag => !tag.Value.Empty())
.Select(tag => tag.Value.ToLower());
var title = matchTitle.Groups["title"].Captures.Cast<Capture>().First().Value;
var title = matchTitle.Groups["title"].Value;
if (matchTitle.Groups["tags1"].Captures.Empty())
{