Improve Anime Detection (#320)

* Improve Anime Detection
This commit is contained in:
rlauuzo 2024-10-02 14:10:42 +02:00 committed by GitHub
parent 3bce9a4370
commit 4f1ce3041a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -4,6 +4,7 @@ using System.IO;
using System.Linq; using System.Linq;
using ConfusedPolarBear.Plugin.IntroSkipper.Data; using ConfusedPolarBear.Plugin.IntroSkipper.Data;
using Jellyfin.Data.Enums; using Jellyfin.Data.Enums;
using Jellyfin.Extensions;
using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.TV; using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Library;
@ -184,6 +185,11 @@ public class QueueManager(ILogger<QueueManager> logger, ILibraryManager libraryM
return; return;
} }
var isAnime = seasonEpisodes.FirstOrDefault()?.IsAnime ??
(pluginInstance.GetItem(episode.SeriesId) is Series series &&
(series.Tags.Contains("anime", StringComparison.OrdinalIgnoreCase) ||
series.Genres.Contains("anime", StringComparison.OrdinalIgnoreCase)));
// Limit analysis to the first X% of the episode and at most Y minutes. // Limit analysis to the first X% of the episode and at most Y minutes.
// X and Y default to 25% and 10 minutes. // X and Y default to 25% and 10 minutes.
var duration = TimeSpan.FromTicks(episode.RunTimeTicks ?? 0).TotalSeconds; var duration = TimeSpan.FromTicks(episode.RunTimeTicks ?? 0).TotalSeconds;
@ -200,7 +206,7 @@ public class QueueManager(ILogger<QueueManager> logger, ILibraryManager libraryM
SeriesId = episode.SeriesId, SeriesId = episode.SeriesId,
EpisodeId = episode.Id, EpisodeId = episode.Id,
Name = episode.Name, Name = episode.Name,
IsAnime = episode.GetInheritedTags().Contains("anime", StringComparer.OrdinalIgnoreCase), IsAnime = isAnime,
Path = episode.Path, Path = episode.Path,
Duration = Convert.ToInt32(duration), Duration = Convert.ToInt32(duration),
IntroFingerprintEnd = Convert.ToInt32(fingerprintDuration), IntroFingerprintEnd = Convert.ToInt32(fingerprintDuration),