diff options
| author | Bond-009 <bond.009@outlook.com> | 2023-02-16 18:03:48 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-02-16 18:03:48 +0100 |
| commit | 5b8fda13e4ba71ae5797ea380bba681328ae0678 (patch) | |
| tree | 17071e805ad19f516d0802bbc613b1a259accc5b /Emby.Naming | |
| parent | 65f6c2e2fd7b3a7f308463e3bc096ba6e8bf65da (diff) | |
| parent | 59920b4052d60b27b9434058df308c3f30f541c4 (diff) | |
Merge pull request #9319 from Bond-009/alternate
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 8048320400..01e383d1c0 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; |
