Skip to content

Commit

Permalink
Increase robustness of retrieving tmdb id (again) (#194)
Browse files Browse the repository at this point in the history
  • Loading branch information
scampower3 authored Nov 3, 2024
1 parent 462ed4e commit f1c9d78
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion Jellyfin.Plugin.Tvdb/Providers/TvdbMovieProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,9 @@ private void MapMovieToResult(MetadataResult<Movie> result, MovieExtendedRecord
movie.SetProviderIdIfHasValue(MetadataProvider.Zap2It, zap2ItId);

var tmdbId = tvdbMovie.RemoteIds?.FirstOrDefault(x => string.Equals(x.SourceName, "TheMovieDB.com", StringComparison.OrdinalIgnoreCase))?.Id.ToString();
movie.SetProviderIdIfHasValue(MetadataProvider.Tmdb, tmdbId);
// Sometimes, tvdb will return tmdbid as {tmdbid}-{title} like in the tmdb url. Grab the tmdbid only.
var tmdbIdLeft = StringExtensions.LeftPart(tmdbId, '-').ToString();
movie.SetProviderIdIfHasValue(MetadataProvider.Tmdb, tmdbIdLeft);

if (DateTime.TryParse(tvdbMovie.First_release.Date, out var date))
{
Expand Down
4 changes: 3 additions & 1 deletion Jellyfin.Plugin.Tvdb/Providers/TvdbPersonProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,9 @@ private void MapPersonToResult(MetadataResult<Person> result, PeopleExtendedReco
person.SetProviderIdIfHasValue(MetadataProvider.Zap2It, zap2ItId);

var tmdbId = tvdbPerson.RemoteIds?.FirstOrDefault(x => string.Equals(x.SourceName, "TheMovieDB.com", StringComparison.OrdinalIgnoreCase))?.Id.ToString();
person.SetProviderIdIfHasValue(MetadataProvider.Tmdb, tmdbId);
// Sometimes, tvdb will return tmdbid as {tmdbid}-{title} like in the tmdb url. Grab the tmdbid only.
var tmdbIdLeft = StringExtensions.LeftPart(tmdbId, '-').ToString();
person.SetProviderIdIfHasValue(MetadataProvider.Tmdb, tmdbIdLeft);

if (!string.IsNullOrWhiteSpace(tvdbPerson.BirthPlace))
{
Expand Down
4 changes: 3 additions & 1 deletion Jellyfin.Plugin.Tvdb/Providers/TvdbSeriesProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,9 @@ private void MapSeriesToResult(MetadataResult<Series> result, SeriesExtendedReco
series.SetProviderIdIfHasValue(MetadataProvider.Zap2It, zap2ItId);

var tmdbId = tvdbSeries.RemoteIds?.FirstOrDefault(x => string.Equals(x.SourceName, "TheMovieDB.com", StringComparison.OrdinalIgnoreCase))?.Id.ToString();
series.SetProviderIdIfHasValue(MetadataProvider.Tmdb, tmdbId);
// Sometimes, tvdb will return tmdbid as {tmdbid}-{title} like in the tmdb url. Grab the tmdbid only.
var tmdbIdLeft = StringExtensions.LeftPart(tmdbId, '-').ToString();
series.SetProviderIdIfHasValue(MetadataProvider.Tmdb, tmdbIdLeft);

if (Enum.TryParse(tvdbSeries.Status.Name, true, out SeriesStatus seriesStatus))
{
Expand Down

0 comments on commit f1c9d78

Please sign in to comment.