Skip to content

Commit

Permalink
Update to Tvdb sdk 4.7.9.1 (#113)
Browse files Browse the repository at this point in the history
  • Loading branch information
scampower3 authored Feb 29, 2024
1 parent 60b3018 commit a143e0c
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion Jellyfin.Plugin.Tvdb/Jellyfin.Plugin.Tvdb.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<PackageReference Include="Jellyfin.Common" Version="10.*-*" />
<PackageReference Include="Jellyfin.Model" Version="10.*-*" />
<PackageReference Include="Microsoft.Extensions.Http" Version="6.0.0" />
<PackageReference Include="Tvdb.Sdk" Version="4.7.9" />
<PackageReference Include="Tvdb.Sdk" Version="4.7.9.1" />
</ItemGroup>

<!-- Code Analyzers-->
Expand Down
2 changes: 1 addition & 1 deletion Jellyfin.Plugin.Tvdb/Providers/TvdbEpisodeProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ private static MetadataResult<Episode> MapEpisodeToResult(EpisodeInfo id, Episod
result.ResetPeople();

var item = result.Item;
item.SetProviderId(TvdbPlugin.ProviderId, episode.Id.ToString(CultureInfo.InvariantCulture));
item.SetProviderId(TvdbPlugin.ProviderId, episode.Id.GetValueOrDefault().ToString(CultureInfo.InvariantCulture));
var imdbID = episode.RemoteIds.FirstOrDefault(x => string.Equals(x.SourceName, "IMDB", StringComparison.OrdinalIgnoreCase))?.Id;
if (!string.IsNullOrEmpty(imdbID))
{
Expand Down
10 changes: 5 additions & 5 deletions Jellyfin.Plugin.Tvdb/Providers/TvdbMissingEpisodeProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ private static bool EpisodeExists(EpisodeBaseRecord episodeRecord, IReadOnlyList

private static bool EpisodeEquals(Episode episode, EpisodeBaseRecord otherEpisodeRecord)
{
return episode.ContainsEpisodeNumber(otherEpisodeRecord.Number)
return episode.ContainsEpisodeNumber(otherEpisodeRecord.Number.GetValueOrDefault())
&& episode.ParentIndexNumber == otherEpisodeRecord.SeasonNumber;
}

Expand Down Expand Up @@ -191,7 +191,7 @@ private async Task HandleSeries(Series series)

var allEpisodes = await GetAllEpisodes(tvdbId, series.GetPreferredMetadataLanguage()).ConfigureAwait(false);
var allSeasons = allEpisodes
.Select(ep => ep.SeasonNumber)
.Select(ep => ep.SeasonNumber.GetValueOrDefault())
.Distinct()
.ToList();

Expand Down Expand Up @@ -385,7 +385,7 @@ private void AddMissingEpisodes(
var episodeRecord = allEpisodeRecords[i];

// skip if it exists already
if (existingEpisodes.TryGetValue(episodeRecord.SeasonNumber, out var episodes)
if (existingEpisodes.TryGetValue(episodeRecord.SeasonNumber.GetValueOrDefault(), out var episodes)
&& EpisodeExists(episodeRecord, episodes))
{
_logger.LogDebug("{MethodName}: Skip, already existing S{Season:00}E{Episode:00}", nameof(AddMissingEpisodes), episodeRecord.SeasonNumber, episodeRecord.Number);
Expand Down Expand Up @@ -447,7 +447,7 @@ private void AddVirtualEpisode(EpisodeBaseRecord? episode, Season? season)
IndexNumber = episode.Number,
ParentIndexNumber = episode.SeasonNumber,
Id = _libraryManager.GetNewItemId(
season.Series.Id + episode.SeasonNumber.ToString(CultureInfo.InvariantCulture) + "Episode " + episode.Number,
season.Series.Id + episode.SeasonNumber.GetValueOrDefault().ToString(CultureInfo.InvariantCulture) + "Episode " + episode.Number,
typeof(Episode)),
IsVirtualItem = true,
SeasonId = season.Id,
Expand All @@ -467,7 +467,7 @@ private void AddVirtualEpisode(EpisodeBaseRecord? episode, Season? season)
}

newEpisode.PresentationUniqueKey = newEpisode.GetPresentationUniqueKey();
newEpisode.SetProviderId(MetadataProvider.Tvdb, episode.Id.ToString(CultureInfo.InvariantCulture));
newEpisode.SetProviderId(MetadataProvider.Tvdb, episode.Id.GetValueOrDefault().ToString(CultureInfo.InvariantCulture));

_logger.LogDebug(
"Creating virtual episode {SeriesName} S{Season:00}E{Episode:00}",
Expand Down
2 changes: 1 addition & 1 deletion Jellyfin.Plugin.Tvdb/Providers/TvdbPersonImageProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public Task<HttpResponseMessage> GetImageResponse(string url, CancellationToken
}

var actor = await _tvdbClientManager
.GetActorAsync(character.PeopleId, series.GetPreferredMetadataCountryCode(), cancellationToken)
.GetActorAsync(character.PeopleId.GetValueOrDefault(), series.GetPreferredMetadataCountryCode(), cancellationToken)
.ConfigureAwait(false);
return new RemoteImageInfo
{
Expand Down
8 changes: 4 additions & 4 deletions Jellyfin.Plugin.Tvdb/Providers/TvdbSeriesProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ private RemoteSearchResult MapSeriesToRemoteSearchResult(SeriesExtendedRecord se
remoteResult.SetProviderId(MetadataProvider.Imdb, imdbID);
}

remoteResult.SetProviderId(MetadataProvider.Tvdb, series.Id.ToString(CultureInfo.InvariantCulture));
remoteResult.SetProviderId(MetadataProvider.Tvdb, series.Id.GetValueOrDefault().ToString(CultureInfo.InvariantCulture));

return remoteResult;
}
Expand Down Expand Up @@ -272,13 +272,13 @@ await _tvdbClientManager
.ConfigureAwait(false);
var resultData = result;

if (resultData is null || resultData.Count == 0 || resultData[0] is null || resultData[0].Series is null)
if (resultData is null || resultData.Count == 0 || resultData[0] is null || resultData[0].Series is null || resultData[0].Series.Id.HasValue == false)
{
_logger.LogWarning("TvdbSearch: No series found for id: {0}", id);
return null;
}

return resultData[0].Series.Id.ToString(CultureInfo.InvariantCulture);
return resultData[0].Series.Id.GetValueOrDefault().ToString(CultureInfo.InvariantCulture);
}

/// <summary>
Expand Down Expand Up @@ -464,7 +464,7 @@ private async Task Identify(SeriesInfo info)
private static void MapSeriesToResult(MetadataResult<Series> result, SeriesExtendedRecord tvdbSeries, SeriesInfo info)
{
Series series = result.Item;
series.SetProviderId(TvdbPlugin.ProviderId, tvdbSeries.Id.ToString(CultureInfo.InvariantCulture));
series.SetProviderId(TvdbPlugin.ProviderId, tvdbSeries.Id.GetValueOrDefault().ToString(CultureInfo.InvariantCulture));
// Tvdb uses 3 letter code for language (prob ISO 639-2)
// Reverts to OriginalName if no translation is found
series.Name = tvdbSeries.Translations.GetTranslatedNamedOrDefault(info.MetadataLanguage) ?? tvdbSeries.Name;
Expand Down
4 changes: 2 additions & 2 deletions Jellyfin.Plugin.Tvdb/TvdbClientManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -382,13 +382,13 @@ public async Task<IReadOnlyList<ArtworkType>> GetArtworkTypeAsync(CancellationTo

Data2 seriesData = seriesResponse.Data;

if (seriesData == null || seriesData.Episodes == null || seriesData.Episodes.Count == 0)
if (seriesData == null || seriesData.Episodes == null || seriesData.Episodes.Count == 0 || seriesData.Episodes[0].Id.HasValue == false)
{
return null;
}
else
{
return seriesData.Episodes[0].Id.ToString(CultureInfo.InvariantCulture);
return seriesData.Episodes[0].Id.GetValueOrDefault().ToString(CultureInfo.InvariantCulture);
}
}

Expand Down
14 changes: 7 additions & 7 deletions Jellyfin.Plugin.Tvdb/TvdbUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,37 +104,37 @@ public static bool MatchLanguage(string? language, string tvdbLanguage)
/// <returns>List{DayOfWeek}.</returns>
public static IEnumerable<DayOfWeek> GetAirDays(SeriesAirsDays seriesAirsDays)
{
if (seriesAirsDays.Sunday)
if (seriesAirsDays.Sunday.GetValueOrDefault())
{
yield return DayOfWeek.Sunday;
}

if (seriesAirsDays.Monday)
if (seriesAirsDays.Monday.GetValueOrDefault())
{
yield return DayOfWeek.Monday;
}

if (seriesAirsDays.Tuesday)
if (seriesAirsDays.Tuesday.GetValueOrDefault())
{
yield return DayOfWeek.Tuesday;
}

if (seriesAirsDays.Wednesday)
if (seriesAirsDays.Wednesday.GetValueOrDefault())
{
yield return DayOfWeek.Wednesday;
}

if (seriesAirsDays.Thursday)
if (seriesAirsDays.Thursday.GetValueOrDefault())
{
yield return DayOfWeek.Thursday;
}

if (seriesAirsDays.Friday)
if (seriesAirsDays.Friday.GetValueOrDefault())
{
yield return DayOfWeek.Friday;
}

if (seriesAirsDays.Saturday)
if (seriesAirsDays.Saturday.GetValueOrDefault())
{
yield return DayOfWeek.Saturday;
}
Expand Down

0 comments on commit a143e0c

Please sign in to comment.