Skip to content

Commit

Permalink
fix: fix force movie special featurettes
Browse files Browse the repository at this point in the history
  • Loading branch information
revam committed May 2, 2024
1 parent fb4647b commit e657677
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Shokofin/API/Info/SeasonInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ public SeasonInfo(Series series, DateTime? earliestImportedAt, DateTime? lastImp
RelationMap = relationMap;
}

public bool IsExtraEpisode(EpisodeInfo episodeInfo)
=> ExtrasList.Any(eI => eI.Id == episodeInfo.Id);
public bool IsExtraEpisode(EpisodeInfo? episodeInfo)
=> episodeInfo != null && ExtrasList.Any(eI => eI.Id == episodeInfo.Id);

public bool IsEmpty(int offset = 0)
{
Expand Down
8 changes: 4 additions & 4 deletions Shokofin/Resolvers/ShokoResolveManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,7 @@ await Task.WhenAll(allFiles.Select(async (tuple) => {
if (episodeName.Length >= NameCutOff)
episodeName = episodeName[..NameCutOff].Split(' ').SkipLast(1).Join(' ') + "";

var isExtra = season.IsExtraEpisode(episode);
var isExtra = file.EpisodeList.Any(eI => season.IsExtraEpisode(eI));
var nfoFiles = new List<string>();
var folders = new List<string>();
var extrasFolder = file.ExtraType switch {
Expand Down Expand Up @@ -1273,8 +1273,8 @@ private static bool TryGetIdsForPath(string path, [NotNullWhen(true)] out string
.GetAwaiter()
.GetResult();
// Abort if the file was not recognised.
if (file == null || file.ExtraType != null)
// Abort if the file was not recognized.
if (file == null || file.EpisodeList.Any(eI => season.IsExtraEpisode(eI)))
return null;
return new Movie() {
Expand Down Expand Up @@ -1455,7 +1455,7 @@ private async Task<bool> ShouldFilterFile(string partialPath, string fullPath, b
Logger.LogInformation("Found {EpisodeCount} shoko episode(s) for {SeriesName} (Series={SeriesId},File={FileId})", file.EpisodeList.Count, season.Shoko.Name, season.Id, file.Id);

// We're going to post process this file later, but we don't want to include it in our library for now.
if (file.ExtraType != null) {
if (file.EpisodeList.Any(eI => season.IsExtraEpisode(eI))) {
Logger.LogInformation("File was assigned an extra type, ignoring file. (Series={SeriesId},File={FileId})", season.Id, file.Id);
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion Shokofin/Utils/Ordering.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public static int GetEpisodeNumber(ShowInfo showInfo, SeasonInfo seasonInfo, Epi
{
var index = 0;
var offset = 0;
if (episodeInfo.ExtraType != null) {
if (seasonInfo.IsExtraEpisode(episodeInfo)) {
var seasonIndex = showInfo.SeasonList.FindIndex(s => string.Equals(s.Id, seasonInfo.Id));
if (seasonIndex == -1)
throw new System.IndexOutOfRangeException($"Series is not part of the provided group. (Group={showInfo.GroupId},Series={seasonInfo.Id},Episode={episodeInfo.Id})");
Expand Down

0 comments on commit e657677

Please sign in to comment.