Skip to content

Commit

Permalink
fix: add xref group from latest daily server
Browse files Browse the repository at this point in the history
  • Loading branch information
revam committed May 23, 2024
1 parent bc893d0 commit a4438db
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
6 changes: 6 additions & 0 deletions Shokofin/API/Models/CrossReference.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ public class CrossReferencePercentage
/// The raw percentage to "group" the cross-references by.
/// </summary>
public int Size { get; set; }

/// <summary>
/// The assumed number of groups in the release, to group the
/// cross-references by.
/// </summary>
public int? Group { get; set; }
}

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions Shokofin/API/ShokoAPIManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -457,9 +457,9 @@ private Task<FileInfo> CreateFileInfo(File file, string fileId, string seriesId)

// Group and order the episodes.
var groupedEpisodeLists = episodeList
.GroupBy(tuple => (type: tuple.Episode.AniDB.Type, percentage: tuple.CrossReference.Percentage?.Size ?? 100))
.GroupBy(tuple => (type: tuple.Episode.AniDB.Type, group: tuple.CrossReference.Percentage?.Group ?? 1))
.OrderByDescending(a => Array.IndexOf(EpisodePickOrder, a.Key.type))
.ThenByDescending(a => a.Key.percentage)
.ThenBy(a => a.Key.group)
.Select(epList => epList.OrderBy(tuple => tuple.Episode.AniDB.EpisodeNumber).ToList())
.ToList();

Expand Down
4 changes: 2 additions & 2 deletions Shokofin/Resolvers/ShokoResolveManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -860,8 +860,8 @@ await Task.WhenAll(allFiles.Select(async (tuple) => {
ExtraType.Sample => new string[] { "samples" },
_ => new string[] { "extras" },
};
var filePartSuffix = (episodeXref.Percentage?.Size ?? 100) is not 100
? $".pt{episode.Shoko.CrossReferences.Where(xref => xref.ReleaseGroup == episodeXref.ReleaseGroup && xref.Percentage!.Size == episodeXref.Percentage!.Size).ToList().FindIndex(xref => xref.Percentage!.Start == episodeXref.Percentage!.Start && xref.Percentage!.End == episodeXref.Percentage!.End) + 1}"
var filePartSuffix = (episodeXref.Percentage?.Group ?? 1) is not 1
? $".pt{episode.Shoko.CrossReferences.Where(xref => xref.ReleaseGroup == episodeXref.ReleaseGroup && xref.Percentage!.Group == episodeXref.Percentage!.Group).ToList().FindIndex(xref => xref.Percentage!.Start == episodeXref.Percentage!.Start && xref.Percentage!.End == episodeXref.Percentage!.End) + 1}"
: "";
if (isMovieSeason && collectionType is not CollectionType.TvShows) {
if (extrasFolders != null) {
Expand Down

0 comments on commit a4438db

Please sign in to comment.