From 322d6cc65d7fa08c3e6cdb19bd839b3a0a2ba54a Mon Sep 17 00:00:00 2001 From: Martin Date: Mon, 5 Oct 2026 17:52:33 -0400 Subject: [PATCH] feat: only play animated trailers before animated content (v1.0.0.11) An anime trailer could play before live-action content: the genre filter accepts any single shared genre (anime is tagged Animation + Drama/Action/...), and when nothing matched it fell back to the whole pool. Trailers tagged Animation or Anime are now dropped for non-animated features before the filters and the fallback run, so a live-action feature gets no trailer rather than an animated one. Co-Authored-By: Claude Opus 5.5 --- ...fin.Plugin.CinemaTrailers4Jellyfins.csproj | 4 ++-- .../Services/TrailerIntroProvider.cs | 19 ++++++++++++++++--- build.yaml | 14 ++++++-------- 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/Jellyfin.Plugin.CinemaTrailers4Jellyfins/Jellyfin.Plugin.CinemaTrailers4Jellyfins.csproj b/Jellyfin.Plugin.CinemaTrailers4Jellyfins/Jellyfin.Plugin.CinemaTrailers4Jellyfins.csproj index 2701628..58092f9 100644 --- a/Jellyfin.Plugin.CinemaTrailers4Jellyfins/Jellyfin.Plugin.CinemaTrailers4Jellyfins.csproj +++ b/Jellyfin.Plugin.CinemaTrailers4Jellyfins/Jellyfin.Plugin.CinemaTrailers4Jellyfins.csproj @@ -3,8 +3,8 @@ net9.0 Jellyfin.Plugin.CinemaTrailers4Jellyfins - 1.0.0.10 - 1.0.0.10 + 1.0.0.11 + 1.0.0.11 enable false false diff --git a/Jellyfin.Plugin.CinemaTrailers4Jellyfins/Services/TrailerIntroProvider.cs b/Jellyfin.Plugin.CinemaTrailers4Jellyfins/Services/TrailerIntroProvider.cs index f7aa6c7..f200d7f 100644 --- a/Jellyfin.Plugin.CinemaTrailers4Jellyfins/Services/TrailerIntroProvider.cs +++ b/Jellyfin.Plugin.CinemaTrailers4Jellyfins/Services/TrailerIntroProvider.cs @@ -147,9 +147,16 @@ namespace Jellyfin.Plugin.CinemaTrailers4Jellyfins.Services } else { - // Apply enabled filters. If nothing survives, fall back to the full pool. - var filtered = ApplyFilters(pairs, feature, config); - var pool = filtered.Count > 0 ? filtered : pairs; + // Animation is a style, not a topic: animated trailers (anime included) only play + // before animated content. Applied before the fallback below, so a live-action + // feature never gets one — it gets no trailer instead. + var eligible = IsAnimated(feature) + ? pairs + : pairs.Where(p => !IsAnimated(p.Movie)).ToList(); + + // Apply enabled filters. If nothing survives, fall back to the eligible pool. + var filtered = ApplyFilters(eligible, feature, config); + var pool = filtered.Count > 0 ? filtered : eligible; // Prefer unseen trailers within the pool; reset the cycle when all have been shown. pool = ApplyAvoidRepeats(pool, user.Id, config.AvoidRepeats); @@ -229,6 +236,12 @@ namespace Jellyfin.Plugin.CinemaTrailers4Jellyfins.Services return new IntroInfo { ItemId = movie.Id, Path = movie.Path }; } + // TMDB tags anime as "Animation"; anime metadata providers (e.g. AniDB) use "Anime". + private static readonly string[] AnimatedGenres = { "Animation", "Anime" }; + + private static bool IsAnimated(BaseItem item) + => item.Genres.Any(g => AnimatedGenres.Contains(g, StringComparer.OrdinalIgnoreCase)); + private static List<(Movie Movie, BaseItem Trailer)> ApplyFilters( List<(Movie Movie, BaseItem Trailer)> pairs, BaseItem feature, diff --git a/build.yaml b/build.yaml index f676b16..07b8da2 100644 --- a/build.yaml +++ b/build.yaml @@ -1,5 +1,5 @@ --- -version: 1.0.0.10 +version: 1.0.0.11 name: CinemaTrailers4Jellyfins guid: b581493e-1046-40ed-b6dc-cb8027624984 description: > @@ -12,13 +12,11 @@ category: General owner: 514mart targetAbi: 10.11.0.0 changelog: - - Fix trailer downloads, broken by a YouTube change. YouTube no longer - serves combined video+audio files, so the built-in downloader now fetches - the video and audio separately, merges them with ffmpeg (no re-encode) - and deletes the separate files afterwards - - A failed download no longer leaves an empty trailer folder behind. - Empty folders counted toward "Max trailers to keep" (pushing out real - trailers) and were never retried + - Animated trailers (anime included) now only play before animated + content. Before, an anime trailer could play before a live-action + movie or show when they shared a genre like Drama or Action, or when + no trailer matched the genre filter. A live-action feature now gets no + trailer rather than an animated one dotnetProjects: - name: Jellyfin.Plugin.CinemaTrailers4Jellyfins