Skip to content

Commit

Permalink
fix: sanitize release groups in vfs file names
Browse files Browse the repository at this point in the history
- Sanitized release groups (and resolution) before we use them.

- Swapped release group so we first try the short name, then the full name.
  • Loading branch information
revam committed Aug 22, 2024
1 parent 18849ae commit 6700b77
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Shokofin/Resolvers/VirtualFileSystemService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -767,16 +767,16 @@ await Task.WhenAll(allFiles.Select(async (tuple) => {
if (config.VFS_AddReleaseGroup)
extraDetails.Add(
file.Shoko.AniDBData is not null
? !string.IsNullOrEmpty(file.Shoko.AniDBData.ReleaseGroup.Name)
? file.Shoko.AniDBData.ReleaseGroup.Name
: !string.IsNullOrEmpty(file.Shoko.AniDBData.ReleaseGroup.ShortName)
? file.Shoko.AniDBData.ReleaseGroup.ShortName
? !string.IsNullOrEmpty(file.Shoko.AniDBData.ReleaseGroup.ShortName)
? file.Shoko.AniDBData.ReleaseGroup.ShortName
: !string.IsNullOrEmpty(file.Shoko.AniDBData.ReleaseGroup.Name)
? file.Shoko.AniDBData.ReleaseGroup.Name
: $"Release group {file.Shoko.AniDBData.ReleaseGroup.Id}"
: "No Group"
);
if (config.VFS_AddResolution && !string.IsNullOrEmpty(file.Shoko.Resolution))
extraDetails.Add(file.Shoko.Resolution);
var fileName = $"{episodeName} {(extraDetails.Count is > 0 ? $"[{extraDetails.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}]{Path.GetExtension(sourceLocation)}";
var symbolicLinks = folders
.Select(folderPath => Path.Join(folderPath, fileName))
.ToArray();
Expand Down

0 comments on commit 6700b77

Please sign in to comment.