Skip to content

Commit

Permalink
Skip Characters with person name is null / Handle null RemoteIds (#160)
Browse files Browse the repository at this point in the history
  • Loading branch information
scampower3 authored Jul 13, 2024
1 parent ee9d432 commit a2bc157
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
8 changes: 7 additions & 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 Expand Up @@ -274,6 +274,12 @@ private async Task<MetadataResult<Episode>> MapEpisodeToResult(EpisodeInfo id, E
for (var i = 0; i < episode.Characters.Count; ++i)
{
var currentActor = episode.Characters[i];
if (string.IsNullOrEmpty(currentActor.PersonName))
{
// Skip people with no person name
continue;
}

if (string.Equals(currentActor.PeopleType, "Actor", StringComparison.OrdinalIgnoreCase))
{
result.AddPerson(new PersonInfo
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 a2bc157

Please sign in to comment.