Skip to content

Commit

Permalink
fix: remove legacy support for 4.2 in cross-reference by
Browse files Browse the repository at this point in the history
marking the percentage object on the episode reference as non-nullable, since they're always available from 5.0 and onwards.
  • Loading branch information
revam committed Dec 27, 2024
1 parent a5bf0ef commit 3ef0aec
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Shokofin/API/Models/CrossReference.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ public class EpisodeCrossReferenceIDs {
/// <summary>
/// Percentage file is matched to the episode.
/// </summary>
public CrossReferencePercentage? Percentage { get; set; }
public CrossReferencePercentage Percentage { get; set; } = new();
}

public class CrossReferencePercentage {
/// <summary>
/// File/episode cross-reference percentage range end.
/// File/episode cross-reference percentage range start.
/// </summary>
public int Start { get; set; }

Expand Down
6 changes: 3 additions & 3 deletions Shokofin/Resolvers/VirtualFileSystemService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -827,15 +827,15 @@ await Task.WhenAll(allFiles.Select(async (tuple) => {
else {
folders.Add(Path.Join(vfsPath, showFolder, seasonFolder));
episodeName = $"{showName} S{(isSpecial ? 0 : seasonNumber).ToString().PadLeft(2, '0')}E{episodeNumber.ToString().PadLeft(show.EpisodePadding, '0')}";
if ((episodeXref.Percentage?.Group ?? 1) is not 1) {
var list = episode.CrossReferences.Where(xref => xref.ReleaseGroup == episodeXref.ReleaseGroup && xref.Percentage!.Group == episodeXref.Percentage!.Group).ToList();
if (episodeXref.Percentage.Group is not 1) {
var list = episode.CrossReferences.Where(xref => xref.ReleaseGroup == episodeXref.ReleaseGroup && xref.Percentage.Group == episodeXref.Percentage.Group).ToList();
var files = (await Task.WhenAll(list.Select(xref => ApiClient.GetFileByEd2kAndFileSize(xref.ED2K, xref.FileSize))).ConfigureAwait(false))
.OfType<API.Models.File>()
.ToList();
if (files.Count != list.Count)
throw new Exception($"Mismatch between cross-references and files. (FileCount={files.Count},CrossReferenceCount={list.Count},Episode={episode.Id},File={fileId},Series={seriesId})");

var index = list.FindIndex(xref => xref.Percentage!.Start == episodeXref.Percentage!.Start && xref.Percentage!.End == episodeXref.Percentage!.End);
var index = list.FindIndex(xref => xref.Percentage.Start == episodeXref.Percentage.Start && xref.Percentage.End == episodeXref.Percentage.End);
filePartSuffix = $".pt{index + 1}";
fileIdList = files.Select(f => f.Id.ToString()).Join(",");
}
Expand Down

0 comments on commit 3ef0aec

Please sign in to comment.