From a8c12772a40c9596dab085523c83c96b1fad40f9 Mon Sep 17 00:00:00 2001 From: LJQ Date: Mon, 20 May 2024 01:16:43 +0800 Subject: [PATCH 1/5] Restrict some metadata info to Air Order only --- Jellyfin.Plugin.Tvdb/Providers/TvdbEpisodeProvider.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Jellyfin.Plugin.Tvdb/Providers/TvdbEpisodeProvider.cs b/Jellyfin.Plugin.Tvdb/Providers/TvdbEpisodeProvider.cs index 4b199ba..1edf2c8 100644 --- a/Jellyfin.Plugin.Tvdb/Providers/TvdbEpisodeProvider.cs +++ b/Jellyfin.Plugin.Tvdb/Providers/TvdbEpisodeProvider.cs @@ -215,9 +215,6 @@ private async Task> MapEpisodeToResult(EpisodeInfo id, E IndexNumber = id.IndexNumber, ParentIndexNumber = id.ParentIndexNumber, IndexNumberEnd = id.IndexNumberEnd, - AirsBeforeEpisodeNumber = episode.AirsBeforeEpisode, - AirsAfterSeasonNumber = episode.AirsAfterSeason, - AirsBeforeSeasonNumber = episode.AirsBeforeSeason, // Tvdb uses 3 letter code for language (prob ISO 639-2) // Reverts to OriginalName if no translation is found Name = episode.Translations.GetTranslatedNamedOrDefault(id.MetadataLanguage) ?? episode.Name, @@ -232,6 +229,14 @@ private async Task> MapEpisodeToResult(EpisodeInfo id, E var imdbID = episode.RemoteIds.FirstOrDefault(x => string.Equals(x.SourceName, "IMDB", StringComparison.OrdinalIgnoreCase))?.Id; item.SetProviderIdIfHasValue(MetadataProvider.Imdb, imdbID); + // Below metadata info only applicable for Aired Order + if (string.IsNullOrEmpty(id.SeriesDisplayOrder)) + { + item.AirsBeforeEpisodeNumber = episode.AirsBeforeEpisode; + item.AirsAfterSeasonNumber = episode.AirsAfterSeason; + item.AirsBeforeSeasonNumber = episode.AirsBeforeSeason; + } + // Missing episodes loses the episode number when refreshed. if (id.IsMissingEpisode) { From d10dd6ec404fbce0ae6a310e40ed2bc3ce6ec569 Mon Sep 17 00:00:00 2001 From: LJQ Date: Mon, 20 May 2024 02:03:18 +0800 Subject: [PATCH 2/5] Cache fix to account for diff display types --- Jellyfin.Plugin.Tvdb/TvdbClientManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jellyfin.Plugin.Tvdb/TvdbClientManager.cs b/Jellyfin.Plugin.Tvdb/TvdbClientManager.cs index f7b5101..7e1fbeb 100644 --- a/Jellyfin.Plugin.Tvdb/TvdbClientManager.cs +++ b/Jellyfin.Plugin.Tvdb/TvdbClientManager.cs @@ -477,7 +477,7 @@ public async Task> GetArtworkTypeAsync(CancellationTo break; } - key = $"FindTvdbEpisodeId_{seriesTvdbIdString}_{seasonNumber.Value.ToString(CultureInfo.InvariantCulture)}_{episodeNumber.Value.ToString(CultureInfo.InvariantCulture)}"; + key = $"FindTvdbEpisodeId_{seriesTvdbIdString}_{seasonNumber.Value.ToString(CultureInfo.InvariantCulture)}_{episodeNumber.Value.ToString(CultureInfo.InvariantCulture)}_{searchInfo.SeriesDisplayOrder}"; } else if (searchInfo.PremiereDate.HasValue) { From a9fce1e908d3150b0ff71fdefa4e37da28d4e4f5 Mon Sep 17 00:00:00 2001 From: LJQ Date: Mon, 20 May 2024 03:02:27 +0800 Subject: [PATCH 3/5] Fix so that an automatic refresh from changing the display order will ignore the present tvdbid --- Jellyfin.Plugin.Tvdb/Providers/TvdbEpisodeProvider.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jellyfin.Plugin.Tvdb/Providers/TvdbEpisodeProvider.cs b/Jellyfin.Plugin.Tvdb/Providers/TvdbEpisodeProvider.cs index 1edf2c8..99e6fea 100644 --- a/Jellyfin.Plugin.Tvdb/Providers/TvdbEpisodeProvider.cs +++ b/Jellyfin.Plugin.Tvdb/Providers/TvdbEpisodeProvider.cs @@ -168,7 +168,7 @@ private async Task> GetEpisode(EpisodeInfo searchInfo, C var episodeTvdbId = searchInfo.GetTvdbId().ToString(CultureInfo.InvariantCulture); try { - if (string.Equals(episodeTvdbId, "0", StringComparison.OrdinalIgnoreCase) || ignoreTvdbIdField) + if (string.Equals(episodeTvdbId, "0", StringComparison.OrdinalIgnoreCase) || ignoreTvdbIdField || searchInfo.IsAutomated) { episodeTvdbId = await _tvdbClientManager .GetEpisodeTvdbId(searchInfo, searchInfo.MetadataLanguage, cancellationToken) From 492282929beefd18220897f59fc7648e7ea797df Mon Sep 17 00:00:00 2001 From: LJQ Date: Mon, 20 May 2024 03:58:05 +0800 Subject: [PATCH 4/5] Set isAutomatic false for updateTask so as to not change the tvdbid value --- Jellyfin.Plugin.Tvdb/ScheduledTasks/UpdateTask.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Jellyfin.Plugin.Tvdb/ScheduledTasks/UpdateTask.cs b/Jellyfin.Plugin.Tvdb/ScheduledTasks/UpdateTask.cs index 0a59e26..98c055a 100644 --- a/Jellyfin.Plugin.Tvdb/ScheduledTasks/UpdateTask.cs +++ b/Jellyfin.Plugin.Tvdb/ScheduledTasks/UpdateTask.cs @@ -74,6 +74,7 @@ public async Task ExecuteAsync(IProgress progress, CancellationToken can { MetadataRefreshMode = MetadataRefreshMode.FullRefresh, ReplaceAllMetadata = true, + IsAutomated = false, }; double increment = 90.0 / toUpdateItems.Count; double currentProgress = 10; From 9f950d569c4eb2c891875480faeff32556e829e0 Mon Sep 17 00:00:00 2001 From: LJQ Date: Tue, 21 May 2024 02:19:56 +0800 Subject: [PATCH 5/5] Adds data restrict to aired order only for missing data --- .../Providers/TvdbMissingEpisodeProvider.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Jellyfin.Plugin.Tvdb/Providers/TvdbMissingEpisodeProvider.cs b/Jellyfin.Plugin.Tvdb/Providers/TvdbMissingEpisodeProvider.cs index d0d9bd5..0559eb0 100644 --- a/Jellyfin.Plugin.Tvdb/Providers/TvdbMissingEpisodeProvider.cs +++ b/Jellyfin.Plugin.Tvdb/Providers/TvdbMissingEpisodeProvider.cs @@ -449,15 +449,21 @@ private void AddVirtualEpisode(EpisodeBaseRecord? episode, Season? season) IsVirtualItem = true, SeasonId = season.Id, SeriesId = season.Series.Id, - AirsBeforeEpisodeNumber = episode.AirsBeforeEpisode, - AirsAfterSeasonNumber = episode.AirsAfterSeason, - AirsBeforeSeasonNumber = episode.AirsBeforeSeason, Overview = episode.Overview, SeriesName = season.Series.Name, SeriesPresentationUniqueKey = season.SeriesPresentationUniqueKey, SeasonName = season.Name, DateLastSaved = DateTime.UtcNow }; + + // Below metadata info only applicable for Aired Order + if (string.IsNullOrEmpty(season.Series.DisplayOrder)) + { + newEpisode.AirsBeforeEpisodeNumber = episode.AirsBeforeEpisode; + newEpisode.AirsAfterSeasonNumber = episode.AirsAfterSeason; + newEpisode.AirsBeforeSeasonNumber = episode.AirsBeforeSeason; + } + if (DateTime.TryParse(episode!.Aired, out var premiereDate)) { newEpisode.PremiereDate = premiereDate;