From 5c36776f8805174cb1b3e57a0fcf92f2060fa388 Mon Sep 17 00:00:00 2001 From: Mikal Stordal Date: Fri, 1 Nov 2024 14:47:18 +0100 Subject: [PATCH] fix: add fast paths for 1 and 0 xrefs in playlist for videos --- Shoko.Server/Services/GeneratedPlaylistService.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Shoko.Server/Services/GeneratedPlaylistService.cs b/Shoko.Server/Services/GeneratedPlaylistService.cs index 2d99ca4f6..b800e907a 100644 --- a/Shoko.Server/Services/GeneratedPlaylistService.cs +++ b/Shoko.Server/Services/GeneratedPlaylistService.cs @@ -353,6 +353,17 @@ public bool TryParsePlaylist(string[] items, out IReadOnlyList<(IReadOnlyList episodes, IReadOnlyList videos)> GetListForVideo(IVideo video) { var crossReferences = video.CrossReferences; + if (crossReferences.Count is 0) + return []; + + if (crossReferences.Count is 1) + { + if (crossReferences[0].ShokoEpisode is not { } episode) + return []; + + return [([episode], [video])]; + } + var seriesOrder = crossReferences .OrderBy(xref => xref.Order) .Select(xref => xref.AnidbAnimeID)