mirror of https://github.com/Sonarr/Sonarr
Accept full language name as suffix.
This commit is contained in:
parent
cc0dbf1af4
commit
fee8da88a6
|
@ -54,6 +54,8 @@ namespace NzbDrone.Core.Test.ParserTests
|
|||
|
||||
[TestCase("2 Broke Girls - S01E01 - Pilot.en.sub", Language.English)]
|
||||
[TestCase("2 Broke Girls - S01E01 - Pilot.eng.sub", Language.English)]
|
||||
[TestCase("2 Broke Girls - S01E01 - Pilot.English.sub", Language.English)]
|
||||
[TestCase("2 Broke Girls - S01E01 - Pilot.english.sub", Language.English)]
|
||||
[TestCase("2 Broke Girls - S01E01 - Pilot.sub", Language.Unknown)]
|
||||
public void should_parse_subtitle_language(string fileName, Language language)
|
||||
{
|
||||
|
|
|
@ -110,7 +110,7 @@ namespace NzbDrone.Core.Parser
|
|||
{
|
||||
try
|
||||
{
|
||||
Logger.Debug("Parsing language from subtitlte file: {0}", fileName);
|
||||
Logger.Debug("Parsing language from subtitle file: {0}", fileName);
|
||||
|
||||
var simpleFilename = Path.GetFileNameWithoutExtension(fileName);
|
||||
var languageMatch = SubtitleLanguageRegex.Match(simpleFilename);
|
||||
|
@ -123,11 +123,19 @@ namespace NzbDrone.Core.Parser
|
|||
return isoLanguage?.Language ?? Language.Unknown;
|
||||
}
|
||||
|
||||
Logger.Debug("Unable to parse langauge from subtitle file: {0}", fileName);
|
||||
foreach (Language language in Enum.GetValues(typeof(Language)))
|
||||
{
|
||||
if (simpleFilename.EndsWith(language.ToString(), StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return language;
|
||||
}
|
||||
}
|
||||
|
||||
Logger.Debug("Unable to parse language from subtitle file: {0}", fileName);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Debug("Failed parsing langauge from subtitle file: {0}", fileName);
|
||||
Logger.Debug(ex, "Failed parsing language from subtitle file: {0}", fileName);
|
||||
}
|
||||
|
||||
return Language.Unknown;
|
||||
|
|
Loading…
Reference in New Issue