Refactor LanguageParser.ParseLanguageTags() to return List<> instead of IEnumerable. Clean up calls to ParseLanguageTags().

pull/8407/head
Lars Erik Helø 2 years ago committed by Qstick
parent 85112e7fbd
commit 223f04ef46

@ -54,7 +54,7 @@ namespace NzbDrone.Core.Extras.Subtitles
MovieFileId = movie.MovieFileId, MovieFileId = movie.MovieFileId,
RelativePath = movie.Path.GetRelativePath(possibleSubtitleFile), RelativePath = movie.Path.GetRelativePath(possibleSubtitleFile),
Language = LanguageParser.ParseSubtitleLanguage(possibleSubtitleFile), Language = LanguageParser.ParseSubtitleLanguage(possibleSubtitleFile),
LanguageTags = LanguageParser.ParseLanguageTags(possibleSubtitleFile).ToList<string>(), LanguageTags = LanguageParser.ParseLanguageTags(possibleSubtitleFile),
Extension = extension Extension = extension
}; };

@ -185,9 +185,9 @@ namespace NzbDrone.Core.Extras.Subtitles
var subFile = new SubtitleFile var subFile = new SubtitleFile
{ {
Language = language, Language = language,
Extension = extension Extension = extension,
LanguageTags = languageTags
}; };
subFile.LanguageTags = languageTags.ToList();
subFile.RelativePath = PathExtensions.GetRelativePath(sourceFolder, file); subFile.RelativePath = PathExtensions.GetRelativePath(sourceFolder, file);
subtitleFiles.Add(subFile); subtitleFiles.Add(subFile);
} }

@ -346,7 +346,7 @@ namespace NzbDrone.Core.Parser
return languages.DistinctBy(l => (int)l).ToList(); return languages.DistinctBy(l => (int)l).ToList();
} }
public static IEnumerable<string> ParseLanguageTags(string fileName) public static List<string> ParseLanguageTags(string fileName)
{ {
try try
{ {
@ -355,14 +355,14 @@ namespace NzbDrone.Core.Parser
var languageTags = match.Groups["tags"].Captures.Cast<Capture>() var languageTags = match.Groups["tags"].Captures.Cast<Capture>()
.Where(tag => !tag.Value.Empty()) .Where(tag => !tag.Value.Empty())
.Select(tag => tag.Value.ToLower()); .Select(tag => tag.Value.ToLower());
return languageTags; return languageTags.ToList();
} }
catch (Exception ex) catch (Exception ex)
{ {
Logger.Debug(ex, "Failed parsing language tags from subtitle file: {0}", fileName); Logger.Debug(ex, "Failed parsing language tags from subtitle file: {0}", fileName);
} }
return Enumerable.Empty<string>(); return new List<string>();
} }
public static Language ParseSubtitleLanguage(string fileName) public static Language ParseSubtitleLanguage(string fileName)

Loading…
Cancel
Save