From 46d0e62281a755f5d9720924f48a0a3b7f168670 Mon Sep 17 00:00:00 2001 From: LJQ Date: Sat, 13 Jul 2024 18:22:32 +0800 Subject: [PATCH] Fix remoteids from tvdb can be null --- .../Providers/TvdbEpisodeProvider.cs | 2 +- .../Providers/TvdbSeriesProvider.cs | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Jellyfin.Plugin.Tvdb/Providers/TvdbEpisodeProvider.cs b/Jellyfin.Plugin.Tvdb/Providers/TvdbEpisodeProvider.cs index 69c6da3..e811a2d 100644 --- a/Jellyfin.Plugin.Tvdb/Providers/TvdbEpisodeProvider.cs +++ b/Jellyfin.Plugin.Tvdb/Providers/TvdbEpisodeProvider.cs @@ -226,7 +226,7 @@ private async Task> MapEpisodeToResult(EpisodeInfo id, E var item = result.Item; item.SetTvdbId(episode.Id); - var imdbID = episode.RemoteIds.FirstOrDefault(x => string.Equals(x.SourceName, "IMDB", StringComparison.OrdinalIgnoreCase))?.Id; + 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 diff --git a/Jellyfin.Plugin.Tvdb/Providers/TvdbSeriesProvider.cs b/Jellyfin.Plugin.Tvdb/Providers/TvdbSeriesProvider.cs index 8a04c15..e367a02 100644 --- a/Jellyfin.Plugin.Tvdb/Providers/TvdbSeriesProvider.cs +++ b/Jellyfin.Plugin.Tvdb/Providers/TvdbSeriesProvider.cs @@ -165,7 +165,7 @@ private RemoteSearchResult MapSeriesToRemoteSearchResult(SeriesExtendedRecord se remoteResult.ProductionYear = date.Year; } - var imdbID = series.RemoteIds.FirstOrDefault(x => x.SourceName == "IMDB")?.Id; + var imdbID = series.RemoteIds?.FirstOrDefault(x => x.SourceName == "IMDB")?.Id; remoteResult.SetProviderIdIfHasValue(MetadataProvider.Imdb, imdbID); remoteResult.SetTvdbId(series.Id); @@ -350,13 +350,13 @@ private async Task> FindSeriesInternal(string name, str await _tvdbClientManager.GetSeriesExtendedByIdAsync(Convert.ToInt32(seriesSearchResult.Tvdb_id, CultureInfo.InvariantCulture), language, cancellationToken, small: true) .ConfigureAwait(false); - var imdbId = seriesResult.RemoteIds.FirstOrDefault(x => string.Equals(x.SourceName, "IMDB", StringComparison.OrdinalIgnoreCase))?.Id.ToString(); + var imdbId = seriesResult.RemoteIds?.FirstOrDefault(x => string.Equals(x.SourceName, "IMDB", StringComparison.OrdinalIgnoreCase))?.Id.ToString(); remoteSearchResult.SetProviderIdIfHasValue(MetadataProvider.Imdb, imdbId); - var zap2ItId = seriesResult.RemoteIds.FirstOrDefault(x => string.Equals(x.SourceName, "Zap2It", StringComparison.OrdinalIgnoreCase))?.Id.ToString(); + var zap2ItId = seriesResult.RemoteIds?.FirstOrDefault(x => string.Equals(x.SourceName, "Zap2It", StringComparison.OrdinalIgnoreCase))?.Id.ToString(); remoteSearchResult.SetProviderIdIfHasValue(MetadataProvider.Zap2It, zap2ItId); - var tmdbId = seriesResult.RemoteIds.FirstOrDefault(x => string.Equals(x.SourceName, "TheMovieDB.com", StringComparison.OrdinalIgnoreCase))?.Id.ToString(); + var tmdbId = seriesResult.RemoteIds?.FirstOrDefault(x => string.Equals(x.SourceName, "TheMovieDB.com", StringComparison.OrdinalIgnoreCase))?.Id.ToString(); // Sometimes, tvdb will return tmdbid as {tmdbid}-{title} like in the tmdb url. Grab the tmdbid only. var tmdbIdLeft = StringExtensions.LeftPart(tmdbId, '-').ToString(); @@ -456,13 +456,13 @@ private static void MapSeriesToResult(MetadataResult result, SeriesExten // Attempts to default to USA if not found series.OfficialRating = tvdbSeries.ContentRatings.FirstOrDefault(x => string.Equals(x.Country, TvdbCultureInfo.GetCountryInfo(info.MetadataCountryCode)?.ThreeLetterISORegionName, StringComparison.OrdinalIgnoreCase))?.Name ?? tvdbSeries.ContentRatings.FirstOrDefault(x => string.Equals(x.Country, "usa", StringComparison.OrdinalIgnoreCase))?.Name; - var imdbId = tvdbSeries.RemoteIds.FirstOrDefault(x => string.Equals(x.SourceName, "IMDB", StringComparison.OrdinalIgnoreCase))?.Id.ToString(); + var imdbId = tvdbSeries.RemoteIds?.FirstOrDefault(x => string.Equals(x.SourceName, "IMDB", StringComparison.OrdinalIgnoreCase))?.Id.ToString(); series.SetProviderIdIfHasValue(MetadataProvider.Imdb, imdbId); - var zap2ItId = tvdbSeries.RemoteIds.FirstOrDefault(x => string.Equals(x.SourceName, "Zap2It", StringComparison.OrdinalIgnoreCase))?.Id.ToString(); + var zap2ItId = tvdbSeries.RemoteIds?.FirstOrDefault(x => string.Equals(x.SourceName, "Zap2It", StringComparison.OrdinalIgnoreCase))?.Id.ToString(); series.SetProviderIdIfHasValue(MetadataProvider.Zap2It, zap2ItId); - var tmdbId = tvdbSeries.RemoteIds.FirstOrDefault(x => string.Equals(x.SourceName, "TheMovieDB.com", StringComparison.OrdinalIgnoreCase))?.Id.ToString(); + var tmdbId = tvdbSeries.RemoteIds?.FirstOrDefault(x => string.Equals(x.SourceName, "TheMovieDB.com", StringComparison.OrdinalIgnoreCase))?.Id.ToString(); series.SetProviderIdIfHasValue(MetadataProvider.Tmdb, tmdbId); if (Enum.TryParse(tvdbSeries.Status.Name, true, out SeriesStatus seriesStatus))