Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip Characters with person name is null / Handle null RemoteIds #160

Merged
merged 3 commits into from
Jul 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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