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

Update to Tvdb sdk 4.7.9.1 #113

Merged
merged 1 commit into from
Feb 29, 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
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 @@
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 @@
.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)

Check notice

Code scanning / CodeQL

Unnecessarily complex Boolean expression Note

The expression 'A == false' can be simplified to '!A'.
{
_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 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,14 +382,14 @@

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)

Check notice

Code scanning / CodeQL

Unnecessarily complex Boolean expression Note

The expression 'A == false' can be simplified to '!A'.
{
return null;
}
else
{
return seriesData.Episodes[0].Id.ToString(CultureInfo.InvariantCulture);
return seriesData.Episodes[0].Id.GetValueOrDefault().ToString(CultureInfo.InvariantCulture);
}

Check notice

Code scanning / CodeQL

Missed ternary opportunity Note

Both branches of this 'if' statement return - consider using '?' to express intent better.
}

/// <summary>
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