Skip to content

Commit

Permalink
fix: fix part episodes
Browse files Browse the repository at this point in the history
- Move the .ptX in partial episodes so Jellyfin properly recognises the parts.
  • Loading branch information
revam committed Oct 15, 2024
1 parent c940504 commit b1280fb
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions Shokofin/Resolvers/VirtualFileSystemService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -793,9 +793,7 @@ await Task.WhenAll(allFiles.Select(async (tuple) => {
ExtraType.Sample => ["samples"],
_ => ["extras"],
};
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}"
: "";
var filePartSuffix = "";
if (collectionType is CollectionType.movies || (collectionType is null && isMovieSeason)) {
if (extrasFolders != null) {
foreach (var extrasFolder in extrasFolders)
Expand Down Expand Up @@ -823,7 +821,10 @@ 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')}{filePartSuffix}";
episodeName = $"{showName} S{(isSpecial ? 0 : seasonNumber).ToString().PadLeft(2, '0')}E{episodeNumber.ToString().PadLeft(show.EpisodePadding, '0')}";
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}"
: "";
}
}

Expand All @@ -840,7 +841,7 @@ file.Shoko.AniDBData is not null
);
if (config.VFS_AddResolution && !string.IsNullOrEmpty(file.Shoko.Resolution))
extraDetails.Add(file.Shoko.Resolution);
var fileName = $"{episodeName} {(extraDetails.Count is > 0 ? $"[{extraDetails.Select(a => a.ReplaceInvalidPathCharacters()).Join("] [")}] " : "")}[{ShokoSeriesId.Name}={seriesId}] [{ShokoFileId.Name}={fileId}]{Path.GetExtension(sourceLocation)}";
var fileName = $"{episodeName} {(extraDetails.Count is > 0 ? $"[{extraDetails.Select(a => a.ReplaceInvalidPathCharacters()).Join("] [")}] " : "")}[{ShokoSeriesId.Name}={seriesId}] [{ShokoFileId.Name}={fileId}]{filePartSuffix}{Path.GetExtension(sourceLocation)}";
var symbolicLinks = folders
.Select(folderPath => Path.Join(folderPath, fileName))
.ToArray();
Expand Down

0 comments on commit b1280fb

Please sign in to comment.