mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-11-15 09:59:06 -07:00
Semi-revert to prefer old movie grouping behaviour
This commit is contained in:
parent
f274d024ce
commit
4a700778e3
@ -175,7 +175,55 @@ namespace Emby.Naming.Video
|
||||
return videos;
|
||||
}
|
||||
|
||||
return videos.GroupBy(v => new {v.Name, v.Year}).Select(group => new VideoInfo
|
||||
var folderName = Path.GetFileName(Path.GetDirectoryName(videos.First().Files.First().Path));
|
||||
if (!string.IsNullOrEmpty(folderName))
|
||||
{
|
||||
var videosMatchingFolder = new List<VideoInfo>();
|
||||
foreach (VideoInfo video in videos)
|
||||
{
|
||||
// Only interested in single files
|
||||
if (video.Files.Count != 1)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (string.Equals(folderName, video.Name, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
videosMatchingFolder.Add(video);
|
||||
}
|
||||
// Eg. My Movie == My Movie - Some Other Info, TODO doesn't seem like a robust test
|
||||
else if (video.Name.StartsWith(folderName, StringComparison.OrdinalIgnoreCase) &&
|
||||
video.Name.Substring(folderName.Length).TrimStart().StartsWith("-"))
|
||||
{
|
||||
videosMatchingFolder.Add(video);
|
||||
}
|
||||
}
|
||||
|
||||
// It is assumed that any non-matching files are random samples, trailers, extras etc.
|
||||
// So if there's at least one video file matching the folder name, skip the rest.
|
||||
if (videosMatchingFolder.Count > 0)
|
||||
{
|
||||
var primary = videosMatchingFolder.First();
|
||||
var remainingVideos = videosMatchingFolder.Skip(1);
|
||||
var videoInfo = new VideoInfo
|
||||
{
|
||||
Name = folderName,
|
||||
Year = videosMatchingFolder.First().Year,
|
||||
Files = videosMatchingFolder.First().Files,
|
||||
AlternateVersions = new List<VideoFileInfo>(),
|
||||
Extras = primary.Extras
|
||||
};
|
||||
foreach (VideoInfo video in remainingVideos)
|
||||
{
|
||||
videoInfo.AlternateVersions.Add(video.Files.First());
|
||||
videoInfo.Extras.AddRange(video.Extras);
|
||||
}
|
||||
|
||||
return new[] { videoInfo };
|
||||
}
|
||||
}
|
||||
|
||||
return videos.GroupBy(v => new { v.Name, v.Year }).Select(group => new VideoInfo
|
||||
{
|
||||
// Because of the grouping, we can grab the information from the first movie and make it primary
|
||||
// The remaining movie matches are 'alternate versions'
|
||||
|
Loading…
Reference in New Issue
Block a user