Fixed: Subtitle tags from existing subtitle files being lost during rename

Closes #5577
pull/5582/head
Lars 2 years ago committed by GitHub
parent 8c50cd061e
commit 3141bf7f9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using NLog;
@ -78,6 +78,7 @@ namespace NzbDrone.Core.Extras.Subtitles
EpisodeFileId = localEpisode.Episodes.First().EpisodeFileId,
RelativePath = series.Path.GetRelativePath(possibleSubtitleFile),
Language = LanguageParser.ParseSubtitleLanguage(possibleSubtitleFile),
LanguageTags = LanguageParser.ParseLanguageTags(possibleSubtitleFile),
Extension = extension
};

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

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

Loading…
Cancel
Save