diff options
| author | Bond_009 <bond.009@outlook.com> | 2023-02-15 18:05:49 +0100 |
|---|---|---|
| committer | Bond_009 <bond.009@outlook.com> | 2023-02-15 18:05:49 +0100 |
| commit | 59920b4052d60b27b9434058df308c3f30f541c4 (patch) | |
| tree | b8b7c706767b54d8a4a28e24639ef70879a80176 /Emby.Naming | |
| parent | 87b2bc5dc4b19f275488178fec25e56e23047fec (diff) | |
Make exact match primary video
Diffstat (limited to 'Emby.Naming')
| -rw-r--r-- | Emby.Naming/Video/VideoListResolver.cs | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/Emby.Naming/Video/VideoListResolver.cs b/Emby.Naming/Video/VideoListResolver.cs index 804832040..01e383d1c 100644 --- a/Emby.Naming/Video/VideoListResolver.cs +++ b/Emby.Naming/Video/VideoListResolver.cs @@ -106,6 +106,7 @@ namespace Emby.Naming.Video } // Cannot use Span inside local functions and delegates thus we cannot use LINQ here nor merge with the above [if] + VideoInfo? primary = null; for (var i = 0; i < videos.Count; i++) { var video = videos[i]; @@ -118,25 +119,24 @@ namespace Emby.Naming.Video { return videos; } + + if (folderName.Equals(Path.GetFileNameWithoutExtension(video.Files[0].Path.AsSpan()), StringComparison.Ordinal)) + { + primary = video; + } } // The list is created and overwritten in the caller, so we are allowed to do in-place sorting videos.Sort((x, y) => string.Compare(x.Name, y.Name, StringComparison.Ordinal)); + primary ??= videos[0]; + videos.Remove(primary); var list = new List<VideoInfo> { - videos[0] + primary }; - var alternateVersionsLen = videos.Count - 1; - var alternateVersions = new VideoFileInfo[alternateVersionsLen]; - for (int i = 0; i < alternateVersionsLen; i++) - { - var video = videos[i + 1]; - alternateVersions[i] = video.Files[0]; - } - - list[0].AlternateVersions = alternateVersions; + list[0].AlternateVersions = videos.Select(x => x.Files[0]).ToArray(); list[0].Name = folderName.ToString(); return list; |
