Skip to content

Commit

Permalink
Merge pull request #21 from jellyfin/revert-isvalidseries
Browse files Browse the repository at this point in the history
revert IsValidSeries refactor
  • Loading branch information
crobibero authored Mar 5, 2021
2 parents 847b654 + 26ab588 commit 4da6fa1
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Jellyfin.Plugin.Tvdb/Providers/TvdbEpisodeImageProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public async Task<IEnumerable<RemoteImageInfo>> GetImages(BaseItem item, Cancell
var series = episode.Series;
var imageResult = new List<RemoteImageInfo>();
var language = item.GetPreferredMetadataLanguage();
if (series != null && TvdbSeriesProvider.IsValidSeries(series))
if (series != null && TvdbSeriesProvider.IsValidSeries(series.ProviderIds))
{
// Process images
try
Expand Down
4 changes: 2 additions & 2 deletions Jellyfin.Plugin.Tvdb/Providers/TvdbEpisodeProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public async Task<IEnumerable<RemoteSearchResult>> GetSearchResults(EpisodeInfo

// Either an episode number or date must be provided; and the dictionary of provider ids must be valid
if ((searchInfo.IndexNumber == null && searchInfo.PremiereDate == null)
|| !TvdbSeriesProvider.IsValidSeries(searchInfo))
|| !TvdbSeriesProvider.IsValidSeries(searchInfo.SeriesProviderIds))
{
return list;
}
Expand Down Expand Up @@ -85,7 +85,7 @@ public async Task<MetadataResult<Episode>> GetMetadata(EpisodeInfo searchInfo, C
QueriedById = true
};

if (TvdbSeriesProvider.IsValidSeries(searchInfo) &&
if (TvdbSeriesProvider.IsValidSeries(searchInfo.SeriesProviderIds) &&
(searchInfo.IndexNumber.HasValue || searchInfo.PremiereDate.HasValue))
{
result = await GetEpisode(searchInfo, cancellationToken).ConfigureAwait(false);
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 @@ -71,7 +71,7 @@ public IEnumerable<ImageType> GetSupportedImages(BaseItem item)
EnableImages = false
}
}).Cast<Series>()
.Where(TvdbSeriesProvider.IsValidSeries)
.Where(i => TvdbSeriesProvider.IsValidSeries(i.ProviderIds))
.ToList();

var infos = (await Task.WhenAll(seriesWithPerson.Select(async i =>
Expand Down
2 changes: 1 addition & 1 deletion Jellyfin.Plugin.Tvdb/Providers/TvdbSeasonImageProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public async Task<IEnumerable<RemoteImageInfo>> GetImages(BaseItem item, Cancell
var season = (Season)item;
var series = season.Series;

if (series == null || !season.IndexNumber.HasValue || !TvdbSeriesProvider.IsValidSeries(series))
if (series == null || !season.IndexNumber.HasValue || !TvdbSeriesProvider.IsValidSeries(series.ProviderIds))
{
return Enumerable.Empty<RemoteImageInfo>();
}
Expand Down
2 changes: 1 addition & 1 deletion Jellyfin.Plugin.Tvdb/Providers/TvdbSeriesImageProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public IEnumerable<ImageType> GetSupportedImages(BaseItem item)
/// <inheritdoc />
public async Task<IEnumerable<RemoteImageInfo>> GetImages(BaseItem item, CancellationToken cancellationToken)
{
if (!TvdbSeriesProvider.IsValidSeries(item))
if (!TvdbSeriesProvider.IsValidSeries(item.ProviderIds))
{
return Enumerable.Empty<RemoteImageInfo>();
}
Expand Down
16 changes: 8 additions & 8 deletions Jellyfin.Plugin.Tvdb/Providers/TvdbSeriesProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public TvdbSeriesProvider(IHttpClientFactory httpClientFactory, ILogger<TvdbSeri
/// <inheritdoc />
public async Task<IEnumerable<RemoteSearchResult>> GetSearchResults(SeriesInfo searchInfo, CancellationToken cancellationToken)
{
if (IsValidSeries(searchInfo))
if (IsValidSeries(searchInfo.ProviderIds))
{
return await FetchSeriesSearchResult(searchInfo, cancellationToken).ConfigureAwait(false);
}
Expand All @@ -68,15 +68,15 @@ public async Task<MetadataResult<Series>> GetMetadata(SeriesInfo itemId, Cancell
QueriedById = true
};

if (!IsValidSeries(itemId))
if (!IsValidSeries(itemId.ProviderIds))
{
result.QueriedById = false;
await Identify(itemId).ConfigureAwait(false);
}

cancellationToken.ThrowIfCancellationRequested();

if (IsValidSeries(itemId))
if (IsValidSeries(itemId.ProviderIds))
{
result.Item = new Series();
result.HasMetadata = true;
Expand All @@ -97,13 +97,13 @@ public Task<HttpResponseMessage> GetImageResponse(string url, CancellationToken
/// <summary>
/// Check whether a dictionary of provider IDs includes an entry for a valid TV metadata provider.
/// </summary>
/// <param name="series">The instance of <see cref="IHasProviderIds"/> to check.</param>
/// <param name="ids">The provider IDs to check.</param>
/// <returns>True, if the series contains a valid TV provider ID, otherwise false.</returns>
internal static bool IsValidSeries(IHasProviderIds series)
internal static bool IsValidSeries(Dictionary<string, string> ids)
{
return !string.IsNullOrEmpty(series.GetProviderId(MetadataProvider.Tvdb)) ||
!string.IsNullOrEmpty(series.GetProviderId(MetadataProvider.Imdb)) ||
!string.IsNullOrEmpty(series.GetProviderId(MetadataProvider.Zap2It));
return (ids.TryGetValue(MetadataProvider.Tvdb.ToString(), out var tvdbId) && !string.IsNullOrEmpty(tvdbId))
|| (ids.TryGetValue(MetadataProvider.Imdb.ToString(), out var imdbId) && !string.IsNullOrEmpty(imdbId))
|| (ids.TryGetValue(MetadataProvider.Zap2It.ToString(), out var zap2ItId) && !string.IsNullOrEmpty(zap2ItId));
}

private async Task<IEnumerable<RemoteSearchResult>> FetchSeriesSearchResult(SeriesInfo seriesInfo, CancellationToken cancellationToken)
Expand Down

0 comments on commit 4da6fa1

Please sign in to comment.