mirror of
https://github.com/Radarr/Radarr.git
synced 2024-09-11 12:02:35 +02:00
Refactor LanguageParser.ParseLanguageTags() to return List<> instead of IEnumerable. Clean up calls to ParseLanguageTags().
This commit is contained in:
parent
85112e7fbd
commit
223f04ef46
@ -54,7 +54,7 @@ public override IEnumerable<ExtraFile> ProcessFiles(Movie movie, List<string> fi
|
|||||||
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 @@ public override IEnumerable<ExtraFile> ImportFiles(LocalMovie localMovie, MovieF
|
|||||||
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 @@ public static List<Language> ParseLanguages(string title)
|
|||||||
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 @@ public static IEnumerable<string> ParseLanguageTags(string fileName)
|
|||||||
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…
Reference in New Issue
Block a user