try to account for sloppy subtitle file naming
This commit is contained in:
parent
fda7c3e9f8
commit
0dcd698c17
|
@ -33,12 +33,14 @@ namespace MediaBrowser.Providers.MediaInfo
|
||||||
var streams = new List<MediaStream>();
|
var streams = new List<MediaStream>();
|
||||||
|
|
||||||
var videoFileNameWithoutExtension = _fileSystem.GetFileNameWithoutExtension(video.Path);
|
var videoFileNameWithoutExtension = _fileSystem.GetFileNameWithoutExtension(video.Path);
|
||||||
|
videoFileNameWithoutExtension = NormalizeFilenameForSubtitleComparison(videoFileNameWithoutExtension);
|
||||||
|
|
||||||
foreach (var file in files)
|
foreach (var file in files)
|
||||||
{
|
{
|
||||||
var fullName = file.FullName;
|
var fullName = file.FullName;
|
||||||
|
|
||||||
var fileNameWithoutExtension = _fileSystem.GetFileNameWithoutExtension(file);
|
var fileNameWithoutExtension = _fileSystem.GetFileNameWithoutExtension(file);
|
||||||
|
fileNameWithoutExtension = NormalizeFilenameForSubtitleComparison(fileNameWithoutExtension);
|
||||||
|
|
||||||
var codec = Path.GetExtension(fullName).ToLower().TrimStart('.');
|
var codec = Path.GetExtension(fullName).ToLower().TrimStart('.');
|
||||||
|
|
||||||
|
@ -59,6 +61,8 @@ namespace MediaBrowser.Providers.MediaInfo
|
||||||
var isForced = fullName.IndexOf(".forced.", StringComparison.OrdinalIgnoreCase) != -1 ||
|
var isForced = fullName.IndexOf(".forced.", StringComparison.OrdinalIgnoreCase) != -1 ||
|
||||||
fullName.IndexOf(".foreign.", StringComparison.OrdinalIgnoreCase) != -1;
|
fullName.IndexOf(".foreign.", StringComparison.OrdinalIgnoreCase) != -1;
|
||||||
|
|
||||||
|
var isDefault = fullName.IndexOf(".default.", StringComparison.OrdinalIgnoreCase) != -1;
|
||||||
|
|
||||||
// Support xbmc naming conventions - 300.spanish.srt
|
// Support xbmc naming conventions - 300.spanish.srt
|
||||||
var language = fileNameWithoutExtension
|
var language = fileNameWithoutExtension
|
||||||
.Replace(".forced", string.Empty, StringComparison.OrdinalIgnoreCase)
|
.Replace(".forced", string.Empty, StringComparison.OrdinalIgnoreCase)
|
||||||
|
@ -84,7 +88,8 @@ namespace MediaBrowser.Providers.MediaInfo
|
||||||
Path = fullName,
|
Path = fullName,
|
||||||
Codec = codec,
|
Codec = codec,
|
||||||
Language = language,
|
Language = language,
|
||||||
IsForced = isForced
|
IsForced = isForced,
|
||||||
|
IsDefault = isDefault
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -92,6 +97,18 @@ namespace MediaBrowser.Providers.MediaInfo
|
||||||
return streams;
|
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
|
private static IEnumerable<string> SubtitleExtensions
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
|
Loading…
Reference in New Issue
Block a user