From 68aa53979664781fbc5ba91d2c64c972f7b76e1d Mon Sep 17 00:00:00 2001 From: LJQ Date: Sat, 10 Aug 2024 21:48:50 +0800 Subject: [PATCH 1/3] Add Configuration --- .../Configuration/PluginConfiguration.cs | 12 +++++++--- .../Configuration/config.html | 23 +++++++++++++------ 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/Jellyfin.Plugin.Tvdb/Configuration/PluginConfiguration.cs b/Jellyfin.Plugin.Tvdb/Configuration/PluginConfiguration.cs index 00e57ae..30c4abf 100644 --- a/Jellyfin.Plugin.Tvdb/Configuration/PluginConfiguration.cs +++ b/Jellyfin.Plugin.Tvdb/Configuration/PluginConfiguration.cs @@ -52,14 +52,19 @@ public int CacheDurationInDays public bool ImportSeasonName { get; set; } = false; /// - /// Gets or sets a value indicating whether to include missing specials. + /// Gets or sets a value indicating whether to fallback to original language. + /// + public bool FallbackToOriginalLanguage { get; set; } = false; + + /// + /// Gets or sets a value indicating whether to include missing specials for Missing Episode Provider. /// public bool IncludeMissingSpecials { get; set; } = true; /// - /// Gets or sets a value indicating whether to fallback to original language. + /// Gets or sets a value indicating whether to remove all missing episodes on refresh for Missing Episode Provider. /// - public bool FallbackToOriginalLanguage { get; set; } = false; + public bool RemoveAllMissingEpisodesOnRefresh { get; set; } = false; /// /// Gets or sets the metadata update in hours for the Check for Metadata Updates Scheduled Task. @@ -89,5 +94,6 @@ public int MetadataUpdateInHours /// Gets or sets a value indicating whether to update movie for the Check for Metadata Updates Scheduled Task. /// public bool UpdateMovieScheduledTask { get; set; } = false; + } } diff --git a/Jellyfin.Plugin.Tvdb/Configuration/config.html b/Jellyfin.Plugin.Tvdb/Configuration/config.html index 309668f..0725e26 100644 --- a/Jellyfin.Plugin.Tvdb/Configuration/config.html +++ b/Jellyfin.Plugin.Tvdb/Configuration/config.html @@ -44,15 +44,22 @@

TheTVDB Settings:

+ +
+

Missing Episode Provider Settings:

+

Check for Metadata Updates Scheduled Task Settings:

@@ -102,9 +109,10 @@

Check for Metadata Updates Scheduled Task Settings:

Check for Metadata Updates Scheduled Task Settings: Date: Sat, 10 Aug 2024 22:05:51 +0800 Subject: [PATCH 2/3] Add removal logic --- .../Configuration/PluginConfiguration.cs | 1 - .../Providers/TvdbMissingEpisodeProvider.cs | 24 ++++++++++++++++--- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/Jellyfin.Plugin.Tvdb/Configuration/PluginConfiguration.cs b/Jellyfin.Plugin.Tvdb/Configuration/PluginConfiguration.cs index 30c4abf..b45fce6 100644 --- a/Jellyfin.Plugin.Tvdb/Configuration/PluginConfiguration.cs +++ b/Jellyfin.Plugin.Tvdb/Configuration/PluginConfiguration.cs @@ -94,6 +94,5 @@ public int MetadataUpdateInHours /// Gets or sets a value indicating whether to update movie for the Check for Metadata Updates Scheduled Task. /// public bool UpdateMovieScheduledTask { get; set; } = false; - } } diff --git a/Jellyfin.Plugin.Tvdb/Providers/TvdbMissingEpisodeProvider.cs b/Jellyfin.Plugin.Tvdb/Providers/TvdbMissingEpisodeProvider.cs index 3500254..d6ab959 100644 --- a/Jellyfin.Plugin.Tvdb/Providers/TvdbMissingEpisodeProvider.cs +++ b/Jellyfin.Plugin.Tvdb/Providers/TvdbMissingEpisodeProvider.cs @@ -64,6 +64,8 @@ public TvdbMissingEpisodeProvider( private static bool IncludeMissingSpecials => TvdbPlugin.Instance?.Configuration.IncludeMissingSpecials ?? false; + private static bool RemoveAllMissingEpisodesOnRefresh => TvdbPlugin.Instance?.Configuration.RemoveAllMissingEpisodesOnRefresh ?? false; + private static bool EpisodeExists(EpisodeBaseRecord episodeRecord, IReadOnlyList existingEpisodes) { return existingEpisodes.Any(episode => EpisodeEquals(episode, episodeRecord)); @@ -146,7 +148,15 @@ private async Task HandleSeries(Series series) } } - var allEpisodes = await GetAllEpisodes(tvdbId, series.DisplayOrder, series.GetPreferredMetadataLanguage()).ConfigureAwait(false); + IReadOnlyList? allEpisodes = null; + if (RemoveAllMissingEpisodesOnRefresh) + { + allEpisodes = Enumerable.Empty().ToList(); + } + else + { + allEpisodes = await GetAllEpisodes(tvdbId, series.DisplayOrder, series.GetPreferredMetadataLanguage()).ConfigureAwait(false); + } if (!IncludeMissingSpecials) { @@ -189,8 +199,16 @@ private async Task HandleSeason(Season season, IReadOnlyList? } var tvdbId = series.GetTvdbId(); - var allEpisodes = allEpisodesRemote ?? await GetAllEpisodes(tvdbId, series.DisplayOrder, season.GetPreferredMetadataLanguage()) - .ConfigureAwait(false); + IReadOnlyList? allEpisodes = null; + if (RemoveAllMissingEpisodesOnRefresh) + { + allEpisodes = Enumerable.Empty().ToList(); + } + else + { + allEpisodes = allEpisodesRemote ?? await GetAllEpisodes(tvdbId, series.DisplayOrder, season.GetPreferredMetadataLanguage()) + .ConfigureAwait(false); + } // Skip if called from HandleSeries since it will be filtered there, allEpisodesRemote will not be null when called from HandleSeries // Remove specials if IncludeMissingSpecials is false From 8d18cf8ab49e2cecda9204efca97ae7d40856647 Mon Sep 17 00:00:00 2001 From: LJQ Date: Sat, 10 Aug 2024 22:13:13 +0800 Subject: [PATCH 3/3] Tenary --- .../Providers/TvdbMissingEpisodeProvider.cs | 26 +++++-------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/Jellyfin.Plugin.Tvdb/Providers/TvdbMissingEpisodeProvider.cs b/Jellyfin.Plugin.Tvdb/Providers/TvdbMissingEpisodeProvider.cs index d6ab959..b7788e3 100644 --- a/Jellyfin.Plugin.Tvdb/Providers/TvdbMissingEpisodeProvider.cs +++ b/Jellyfin.Plugin.Tvdb/Providers/TvdbMissingEpisodeProvider.cs @@ -148,15 +148,9 @@ private async Task HandleSeries(Series series) } } - IReadOnlyList? allEpisodes = null; - if (RemoveAllMissingEpisodesOnRefresh) - { - allEpisodes = Enumerable.Empty().ToList(); - } - else - { - allEpisodes = await GetAllEpisodes(tvdbId, series.DisplayOrder, series.GetPreferredMetadataLanguage()).ConfigureAwait(false); - } + var allEpisodes = RemoveAllMissingEpisodesOnRefresh ? + Enumerable.Empty().ToList() : + await GetAllEpisodes(tvdbId, series.DisplayOrder, series.GetPreferredMetadataLanguage()).ConfigureAwait(false); if (!IncludeMissingSpecials) { @@ -199,17 +193,11 @@ private async Task HandleSeason(Season season, IReadOnlyList? } var tvdbId = series.GetTvdbId(); - IReadOnlyList? allEpisodes = null; - if (RemoveAllMissingEpisodesOnRefresh) - { - allEpisodes = Enumerable.Empty().ToList(); - } - else - { - allEpisodes = allEpisodesRemote ?? await GetAllEpisodes(tvdbId, series.DisplayOrder, season.GetPreferredMetadataLanguage()) + var allEpisodes = RemoveAllMissingEpisodesOnRefresh ? + Enumerable.Empty().ToList() : + allEpisodesRemote ?? + await GetAllEpisodes(tvdbId, series.DisplayOrder, season.GetPreferredMetadataLanguage()) .ConfigureAwait(false); - } - // Skip if called from HandleSeries since it will be filtered there, allEpisodesRemote will not be null when called from HandleSeries // Remove specials if IncludeMissingSpecials is false if (allEpisodesRemote is null && !IncludeMissingSpecials)