From 91556aed2861a65ebb0c444283bb8eb5f2e08d40 Mon Sep 17 00:00:00 2001 From: LJQ Date: Thu, 29 Feb 2024 00:07:19 +0800 Subject: [PATCH] Update to Tvdb sdk 4.7.9.1 --- Jellyfin.Plugin.Tvdb/Jellyfin.Plugin.Tvdb.csproj | 2 +- .../Providers/TvdbEpisodeProvider.cs | 2 +- .../Providers/TvdbMissingEpisodeProvider.cs | 10 +++++----- .../Providers/TvdbPersonImageProvider.cs | 2 +- .../Providers/TvdbSeriesProvider.cs | 8 ++++---- Jellyfin.Plugin.Tvdb/TvdbClientManager.cs | 4 ++-- Jellyfin.Plugin.Tvdb/TvdbUtils.cs | 14 +++++++------- 7 files changed, 21 insertions(+), 21 deletions(-) diff --git a/Jellyfin.Plugin.Tvdb/Jellyfin.Plugin.Tvdb.csproj b/Jellyfin.Plugin.Tvdb/Jellyfin.Plugin.Tvdb.csproj index c42de24..91810ae 100644 --- a/Jellyfin.Plugin.Tvdb/Jellyfin.Plugin.Tvdb.csproj +++ b/Jellyfin.Plugin.Tvdb/Jellyfin.Plugin.Tvdb.csproj @@ -25,7 +25,7 @@ - + diff --git a/Jellyfin.Plugin.Tvdb/Providers/TvdbEpisodeProvider.cs b/Jellyfin.Plugin.Tvdb/Providers/TvdbEpisodeProvider.cs index abb4f07..73621b2 100644 --- a/Jellyfin.Plugin.Tvdb/Providers/TvdbEpisodeProvider.cs +++ b/Jellyfin.Plugin.Tvdb/Providers/TvdbEpisodeProvider.cs @@ -220,7 +220,7 @@ private static MetadataResult MapEpisodeToResult(EpisodeInfo id, Episod result.ResetPeople(); var item = result.Item; - item.SetProviderId(TvdbPlugin.ProviderId, episode.Id.ToString(CultureInfo.InvariantCulture)); + item.SetProviderId(TvdbPlugin.ProviderId, episode.Id.GetValueOrDefault().ToString(CultureInfo.InvariantCulture)); var imdbID = episode.RemoteIds.FirstOrDefault(x => string.Equals(x.SourceName, "IMDB", StringComparison.OrdinalIgnoreCase))?.Id; if (!string.IsNullOrEmpty(imdbID)) { diff --git a/Jellyfin.Plugin.Tvdb/Providers/TvdbMissingEpisodeProvider.cs b/Jellyfin.Plugin.Tvdb/Providers/TvdbMissingEpisodeProvider.cs index bbd248d..9b468cf 100644 --- a/Jellyfin.Plugin.Tvdb/Providers/TvdbMissingEpisodeProvider.cs +++ b/Jellyfin.Plugin.Tvdb/Providers/TvdbMissingEpisodeProvider.cs @@ -102,7 +102,7 @@ private static bool EpisodeExists(EpisodeBaseRecord episodeRecord, IReadOnlyList private static bool EpisodeEquals(Episode episode, EpisodeBaseRecord otherEpisodeRecord) { - return episode.ContainsEpisodeNumber(otherEpisodeRecord.Number) + return episode.ContainsEpisodeNumber(otherEpisodeRecord.Number.GetValueOrDefault()) && episode.ParentIndexNumber == otherEpisodeRecord.SeasonNumber; } @@ -191,7 +191,7 @@ private async Task HandleSeries(Series series) var allEpisodes = await GetAllEpisodes(tvdbId, series.GetPreferredMetadataLanguage()).ConfigureAwait(false); var allSeasons = allEpisodes - .Select(ep => ep.SeasonNumber) + .Select(ep => ep.SeasonNumber.GetValueOrDefault()) .Distinct() .ToList(); @@ -385,7 +385,7 @@ private void AddMissingEpisodes( var episodeRecord = allEpisodeRecords[i]; // skip if it exists already - if (existingEpisodes.TryGetValue(episodeRecord.SeasonNumber, out var episodes) + if (existingEpisodes.TryGetValue(episodeRecord.SeasonNumber.GetValueOrDefault(), out var episodes) && EpisodeExists(episodeRecord, episodes)) { _logger.LogDebug("{MethodName}: Skip, already existing S{Season:00}E{Episode:00}", nameof(AddMissingEpisodes), episodeRecord.SeasonNumber, episodeRecord.Number); @@ -447,7 +447,7 @@ private void AddVirtualEpisode(EpisodeBaseRecord? episode, Season? season) IndexNumber = episode.Number, ParentIndexNumber = episode.SeasonNumber, Id = _libraryManager.GetNewItemId( - season.Series.Id + episode.SeasonNumber.ToString(CultureInfo.InvariantCulture) + "Episode " + episode.Number, + season.Series.Id + episode.SeasonNumber.GetValueOrDefault().ToString(CultureInfo.InvariantCulture) + "Episode " + episode.Number, typeof(Episode)), IsVirtualItem = true, SeasonId = season.Id, @@ -467,7 +467,7 @@ private void AddVirtualEpisode(EpisodeBaseRecord? episode, Season? season) } newEpisode.PresentationUniqueKey = newEpisode.GetPresentationUniqueKey(); - newEpisode.SetProviderId(MetadataProvider.Tvdb, episode.Id.ToString(CultureInfo.InvariantCulture)); + newEpisode.SetProviderId(MetadataProvider.Tvdb, episode.Id.GetValueOrDefault().ToString(CultureInfo.InvariantCulture)); _logger.LogDebug( "Creating virtual episode {SeriesName} S{Season:00}E{Episode:00}", diff --git a/Jellyfin.Plugin.Tvdb/Providers/TvdbPersonImageProvider.cs b/Jellyfin.Plugin.Tvdb/Providers/TvdbPersonImageProvider.cs index 82b90a1..480e640 100644 --- a/Jellyfin.Plugin.Tvdb/Providers/TvdbPersonImageProvider.cs +++ b/Jellyfin.Plugin.Tvdb/Providers/TvdbPersonImageProvider.cs @@ -108,7 +108,7 @@ public Task GetImageResponse(string url, CancellationToken } var actor = await _tvdbClientManager - .GetActorAsync(character.PeopleId, series.GetPreferredMetadataCountryCode(), cancellationToken) + .GetActorAsync(character.PeopleId.GetValueOrDefault(), series.GetPreferredMetadataCountryCode(), cancellationToken) .ConfigureAwait(false); return new RemoteImageInfo { diff --git a/Jellyfin.Plugin.Tvdb/Providers/TvdbSeriesProvider.cs b/Jellyfin.Plugin.Tvdb/Providers/TvdbSeriesProvider.cs index 68ad6b8..286da3f 100644 --- a/Jellyfin.Plugin.Tvdb/Providers/TvdbSeriesProvider.cs +++ b/Jellyfin.Plugin.Tvdb/Providers/TvdbSeriesProvider.cs @@ -185,7 +185,7 @@ private RemoteSearchResult MapSeriesToRemoteSearchResult(SeriesExtendedRecord se remoteResult.SetProviderId(MetadataProvider.Imdb, imdbID); } - remoteResult.SetProviderId(MetadataProvider.Tvdb, series.Id.ToString(CultureInfo.InvariantCulture)); + remoteResult.SetProviderId(MetadataProvider.Tvdb, series.Id.GetValueOrDefault().ToString(CultureInfo.InvariantCulture)); return remoteResult; } @@ -272,13 +272,13 @@ await _tvdbClientManager .ConfigureAwait(false); var resultData = result; - if (resultData is null || resultData.Count == 0 || resultData[0] is null || resultData[0].Series is null) + if (resultData is null || resultData.Count == 0 || resultData[0] is null || resultData[0].Series is null || resultData[0].Series.Id.HasValue == false) { _logger.LogWarning("TvdbSearch: No series found for id: {0}", id); return null; } - return resultData[0].Series.Id.ToString(CultureInfo.InvariantCulture); + return resultData[0].Series.Id.GetValueOrDefault().ToString(CultureInfo.InvariantCulture); } /// @@ -464,7 +464,7 @@ private async Task Identify(SeriesInfo info) private static void MapSeriesToResult(MetadataResult result, SeriesExtendedRecord tvdbSeries, SeriesInfo info) { Series series = result.Item; - series.SetProviderId(TvdbPlugin.ProviderId, tvdbSeries.Id.ToString(CultureInfo.InvariantCulture)); + series.SetProviderId(TvdbPlugin.ProviderId, tvdbSeries.Id.GetValueOrDefault().ToString(CultureInfo.InvariantCulture)); // Tvdb uses 3 letter code for language (prob ISO 639-2) // Reverts to OriginalName if no translation is found series.Name = tvdbSeries.Translations.GetTranslatedNamedOrDefault(info.MetadataLanguage) ?? tvdbSeries.Name; diff --git a/Jellyfin.Plugin.Tvdb/TvdbClientManager.cs b/Jellyfin.Plugin.Tvdb/TvdbClientManager.cs index 4a367b6..afe2b1f 100644 --- a/Jellyfin.Plugin.Tvdb/TvdbClientManager.cs +++ b/Jellyfin.Plugin.Tvdb/TvdbClientManager.cs @@ -382,13 +382,13 @@ public async Task> GetArtworkTypeAsync(CancellationTo Data2 seriesData = seriesResponse.Data; - if (seriesData == null || seriesData.Episodes == null || seriesData.Episodes.Count == 0) + if (seriesData == null || seriesData.Episodes == null || seriesData.Episodes.Count == 0 || seriesData.Episodes[0].Id.HasValue == false) { return null; } else { - return seriesData.Episodes[0].Id.ToString(CultureInfo.InvariantCulture); + return seriesData.Episodes[0].Id.GetValueOrDefault().ToString(CultureInfo.InvariantCulture); } } diff --git a/Jellyfin.Plugin.Tvdb/TvdbUtils.cs b/Jellyfin.Plugin.Tvdb/TvdbUtils.cs index 03b64c7..fea2cc3 100644 --- a/Jellyfin.Plugin.Tvdb/TvdbUtils.cs +++ b/Jellyfin.Plugin.Tvdb/TvdbUtils.cs @@ -104,37 +104,37 @@ public static bool MatchLanguage(string? language, string tvdbLanguage) /// List{DayOfWeek}. public static IEnumerable GetAirDays(SeriesAirsDays seriesAirsDays) { - if (seriesAirsDays.Sunday) + if (seriesAirsDays.Sunday.GetValueOrDefault()) { yield return DayOfWeek.Sunday; } - if (seriesAirsDays.Monday) + if (seriesAirsDays.Monday.GetValueOrDefault()) { yield return DayOfWeek.Monday; } - if (seriesAirsDays.Tuesday) + if (seriesAirsDays.Tuesday.GetValueOrDefault()) { yield return DayOfWeek.Tuesday; } - if (seriesAirsDays.Wednesday) + if (seriesAirsDays.Wednesday.GetValueOrDefault()) { yield return DayOfWeek.Wednesday; } - if (seriesAirsDays.Thursday) + if (seriesAirsDays.Thursday.GetValueOrDefault()) { yield return DayOfWeek.Thursday; } - if (seriesAirsDays.Friday) + if (seriesAirsDays.Friday.GetValueOrDefault()) { yield return DayOfWeek.Friday; } - if (seriesAirsDays.Saturday) + if (seriesAirsDays.Saturday.GetValueOrDefault()) { yield return DayOfWeek.Saturday; }