mirror of
https://github.com/Radarr/Radarr.git
synced 2026-04-21 22:05:43 -04:00
New: Preserve language tags when importing subtitle files
This commit is contained in:
committed by
Qstick
parent
b3c3f7ddae
commit
43d77308f9
@@ -4,6 +4,7 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Common.Instrumentation;
|
||||
using NzbDrone.Core.Languages;
|
||||
|
||||
@@ -304,6 +305,25 @@ namespace NzbDrone.Core.Parser
|
||||
return languages.DistinctBy(l => (int)l).ToList();
|
||||
}
|
||||
|
||||
public static IEnumerable<string> ParseLanguageTags(string fileName)
|
||||
{
|
||||
try
|
||||
{
|
||||
var simpleFilename = Path.GetFileNameWithoutExtension(fileName);
|
||||
var match = SubtitleLanguageRegex.Match(simpleFilename);
|
||||
var languageTags = match.Groups["tags"].Captures.Cast<Capture>()
|
||||
.Where(tag => !tag.Value.Empty())
|
||||
.Select(tag => tag.Value.ToLower());
|
||||
return languageTags;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Debug(ex, "Failed parsing language tags from subtitle file: {0}", fileName);
|
||||
}
|
||||
|
||||
return Enumerable.Empty<string>();
|
||||
}
|
||||
|
||||
public static Language ParseSubtitleLanguage(string fileName)
|
||||
{
|
||||
try
|
||||
|
||||
Reference in New Issue
Block a user