aboutsummaryrefslogtreecommitdiff
path: root/Emby.Naming
diff options
context:
space:
mode:
Diffstat (limited to 'Emby.Naming')
-rw-r--r--Emby.Naming/Video/VideoListResolver.cs20
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;