Skip to content

Commit

Permalink
Fix remoteids from tvdb can be null
Browse files Browse the repository at this point in the history
  • Loading branch information
scampower3 committed Jul 13, 2024
1 parent cd21551 commit 46d0e62
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Jellyfin.Plugin.Tvdb/Providers/TvdbEpisodeProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ private async Task<MetadataResult<Episode>> 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
Expand Down
14 changes: 7 additions & 7 deletions Jellyfin.Plugin.Tvdb/Providers/TvdbSeriesProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -350,13 +350,13 @@ private async Task<List<RemoteSearchResult>> 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();
Expand Down Expand Up @@ -456,13 +456,13 @@ private static void MapSeriesToResult(MetadataResult<Series> 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))
Expand Down

0 comments on commit 46d0e62

Please sign in to comment.