try to account for sloppy subtitle file naming

pull/702/head
Luke Pulverenti 9 years ago
parent c39162a056
commit 7f7c847216

@ -33,12 +33,14 @@ namespace MediaBrowser.Providers.MediaInfo
var streams = new List<MediaStream>();
var videoFileNameWithoutExtension = _fileSystem.GetFileNameWithoutExtension(video.Path);
videoFileNameWithoutExtension = NormalizeFilenameForSubtitleComparison(videoFileNameWithoutExtension);
foreach (var file in files)
{
var fullName = file.FullName;
var fileNameWithoutExtension = _fileSystem.GetFileNameWithoutExtension(file);
fileNameWithoutExtension = NormalizeFilenameForSubtitleComparison(fileNameWithoutExtension);
var codec = Path.GetExtension(fullName).ToLower().TrimStart('.');
@ -59,6 +61,8 @@ namespace MediaBrowser.Providers.MediaInfo
var isForced = fullName.IndexOf(".forced.", StringComparison.OrdinalIgnoreCase) != -1 ||
fullName.IndexOf(".foreign.", StringComparison.OrdinalIgnoreCase) != -1;
var isDefault = fullName.IndexOf(".default.", StringComparison.OrdinalIgnoreCase) != -1;
// Support xbmc naming conventions - 300.spanish.srt
var language = fileNameWithoutExtension
.Replace(".forced", string.Empty, StringComparison.OrdinalIgnoreCase)
@ -84,7 +88,8 @@ namespace MediaBrowser.Providers.MediaInfo
Path = fullName,
Codec = codec,
Language = language,
IsForced = isForced
IsForced = isForced,
IsDefault = isDefault
});
}
}
@ -92,6 +97,18 @@ namespace MediaBrowser.Providers.MediaInfo
return streams;
}
private string NormalizeFilenameForSubtitleComparison(string filename)
{
// Try to account for sloppy file naming
filename = filename.Replace("-", string.Empty);
filename = filename.Replace("_", string.Empty);
filename = filename.Replace(" ", string.Empty);
//filename = filename.Replace(".", string.Empty);
return filename;
}
private static IEnumerable<string> SubtitleExtensions
{
get

Loading…
Cancel
Save