Merge pull request #924 from cvium/fix_movie_matching

Use the movie name instead of folder name
This commit is contained in:
Vasily 2019-02-18 15:10:36 +03:00 committed by GitHub
commit f274d024ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -175,23 +175,16 @@ namespace Emby.Naming.Video
return videos; return videos;
} }
var folderName = Path.GetFileName(Path.GetDirectoryName(videos[0].Files[0].Path)); return videos.GroupBy(v => new {v.Name, v.Year}).Select(group => new VideoInfo
if (!string.IsNullOrEmpty(folderName) && folderName.Length > 1)
{ {
var ordered = videos.OrderBy(i => i.Name); // Because of the grouping, we can grab the information from the first movie and make it primary
// The remaining movie matches are 'alternate versions'
return ordered.GroupBy(v => new {v.Name, v.Year}).Select(group => new VideoInfo Name = group.First().Name,
{ Year = group.First().Year,
Name = folderName, Files = group.First().Files,
Year = group.First().Year, AlternateVersions = group.Skip(1).Select(i => i.Files[0]).ToList(),
Files = group.First().Files, Extras = group.First().Extras.Concat(group.Skip(1).SelectMany(i => i.Extras)).ToList()
AlternateVersions = group.Skip(1).Select(i => i.Files[0]).ToList(), });
Extras = group.First().Extras.Concat(group.Skip(1).SelectMany(i => i.Extras)).ToList()
});
}
return videos;
} }
private List<VideoFileInfo> GetExtras(IEnumerable<VideoFileInfo> remainingFiles, List<string> baseNames) private List<VideoFileInfo> GetExtras(IEnumerable<VideoFileInfo> remainingFiles, List<string> baseNames)