Minor improvements to tmdb code
This commit is contained in:
parent
3a238de35e
commit
6def4b06a8
|
@ -67,17 +67,17 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
|
|||
.GetEpisodeAsync(seriesTmdbId, seasonNumber.Value, episodeNumber.Value, language, TmdbUtils.GetImageLanguagesParam(language), cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
if (episodeResult?.Images?.Stills == null)
|
||||
var stills = episodeResult?.Images?.Stills;
|
||||
if (stills == null)
|
||||
{
|
||||
return Enumerable.Empty<RemoteImageInfo>();
|
||||
}
|
||||
|
||||
var remoteImages = new List<RemoteImageInfo>();
|
||||
|
||||
for (var i = 0; i < episodeResult.Images.Stills.Count; i++)
|
||||
var remoteImages = new RemoteImageInfo[stills.Count];
|
||||
for (var i = 0; i < stills.Count; i++)
|
||||
{
|
||||
var image = episodeResult.Images.Stills[i];
|
||||
remoteImages.Add(new RemoteImageInfo
|
||||
var image = stills[i];
|
||||
remoteImages[i] = new RemoteImageInfo
|
||||
{
|
||||
Url = _tmdbClientManager.GetStillUrl(image.FilePath),
|
||||
CommunityRating = image.VoteAverage,
|
||||
|
@ -88,7 +88,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
|
|||
ProviderName = Name,
|
||||
Type = ImageType.Primary,
|
||||
RatingType = RatingType.Score
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
return remoteImages.OrderByLanguageDescending(language);
|
||||
|
|
|
@ -40,30 +40,29 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
|
|||
return Enumerable.Empty<RemoteSearchResult>();
|
||||
}
|
||||
|
||||
var metadataResult = await GetMetadata(searchInfo, cancellationToken);
|
||||
var metadataResult = await GetMetadata(searchInfo, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (!metadataResult.HasMetadata)
|
||||
{
|
||||
return Enumerable.Empty<RemoteSearchResult>();
|
||||
}
|
||||
|
||||
var list = new List<RemoteSearchResult>();
|
||||
|
||||
var item = metadataResult.Item;
|
||||
|
||||
list.Add(new RemoteSearchResult
|
||||
return new[]
|
||||
{
|
||||
IndexNumber = item.IndexNumber,
|
||||
Name = item.Name,
|
||||
ParentIndexNumber = item.ParentIndexNumber,
|
||||
PremiereDate = item.PremiereDate,
|
||||
ProductionYear = item.ProductionYear,
|
||||
ProviderIds = item.ProviderIds,
|
||||
SearchProviderName = Name,
|
||||
IndexNumberEnd = item.IndexNumberEnd
|
||||
});
|
||||
|
||||
return list;
|
||||
new RemoteSearchResult
|
||||
{
|
||||
IndexNumber = item.IndexNumber,
|
||||
Name = item.Name,
|
||||
ParentIndexNumber = item.ParentIndexNumber,
|
||||
PremiereDate = item.PremiereDate,
|
||||
ProductionYear = item.ProductionYear,
|
||||
ProviderIds = item.ProviderIds,
|
||||
SearchProviderName = Name,
|
||||
IndexNumberEnd = item.IndexNumberEnd
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public async Task<MetadataResult<Episode>> GetMetadata(EpisodeInfo info, CancellationToken cancellationToken)
|
||||
|
@ -137,8 +136,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
|
|||
{
|
||||
if (TmdbUtils.IsTrailerType(video))
|
||||
{
|
||||
var videoUrl = string.Format(CultureInfo.InvariantCulture, "http://www.youtube.com/watch?v={0}", video.Key);
|
||||
item.AddTrailerUrl(videoUrl);
|
||||
item.AddTrailerUrl("https://www.youtube.com/watch?v=" + video.Key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,16 +56,17 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
|
|||
.GetSeasonAsync(seriesTmdbId, season.IndexNumber.Value, language, TmdbUtils.GetImageLanguagesParam(language), cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
if (seasonResult?.Images?.Posters == null)
|
||||
var posters = seasonResult?.Images?.Posters;
|
||||
if (posters == null)
|
||||
{
|
||||
return Enumerable.Empty<RemoteImageInfo>();
|
||||
}
|
||||
|
||||
var remoteImages = new List<RemoteImageInfo>();
|
||||
for (var i = 0; i < seasonResult.Images.Posters.Count; i++)
|
||||
var remoteImages = new RemoteImageInfo[posters.Count];
|
||||
for (var i = 0; i < posters.Count; i++)
|
||||
{
|
||||
var image = seasonResult.Images.Posters[i];
|
||||
remoteImages.Add(new RemoteImageInfo
|
||||
var image = posters[i];
|
||||
remoteImages[i] = new RemoteImageInfo
|
||||
{
|
||||
Url = _tmdbClientManager.GetPosterUrl(image.FilePath),
|
||||
CommunityRating = image.VoteAverage,
|
||||
|
@ -76,7 +77,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
|
|||
ProviderName = Name,
|
||||
Type = ImageType.Primary,
|
||||
RatingType = RatingType.Score
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
return remoteImages.OrderByLanguageDescending(language);
|
||||
|
|
|
@ -68,12 +68,15 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
|
|||
return Enumerable.Empty<RemoteImageInfo>();
|
||||
}
|
||||
|
||||
var remoteImages = new List<RemoteImageInfo>();
|
||||
var posters = series.Images.Posters;
|
||||
var backdrops = series.Images.Backdrops;
|
||||
|
||||
for (var i = 0; i < series.Images.Posters.Count; i++)
|
||||
var remoteImages = new RemoteImageInfo[posters.Count + backdrops.Count];
|
||||
|
||||
for (var i = 0; i < posters.Count; i++)
|
||||
{
|
||||
var poster = series.Images.Posters[i];
|
||||
remoteImages.Add(new RemoteImageInfo
|
||||
var poster = posters[i];
|
||||
remoteImages[i] = new RemoteImageInfo
|
||||
{
|
||||
Url = _tmdbClientManager.GetPosterUrl(poster.FilePath),
|
||||
CommunityRating = poster.VoteAverage,
|
||||
|
@ -84,13 +87,13 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
|
|||
ProviderName = Name,
|
||||
Type = ImageType.Primary,
|
||||
RatingType = RatingType.Score
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
for (var i = 0; i < series.Images.Backdrops.Count; i++)
|
||||
for (var i = 0; i < backdrops.Count; i++)
|
||||
{
|
||||
var backdrop = series.Images.Backdrops[i];
|
||||
remoteImages.Add(new RemoteImageInfo
|
||||
remoteImages[posters.Count + i] = new RemoteImageInfo
|
||||
{
|
||||
Url = _tmdbClientManager.GetBackdropUrl(backdrop.FilePath),
|
||||
CommunityRating = backdrop.VoteAverage,
|
||||
|
@ -100,7 +103,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
|
|||
ProviderName = Name,
|
||||
Type = ImageType.Backdrop,
|
||||
RatingType = RatingType.Score
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
return remoteImages.OrderByLanguageDescending(language);
|
||||
|
|
|
@ -66,14 +66,15 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
|
|||
.FindByExternalIdAsync(imdbId, FindExternalSource.Imdb, searchInfo.MetadataLanguage, cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
if (findResult?.TvResults != null)
|
||||
var tvResults = findResult?.TvResults;
|
||||
if (tvResults != null)
|
||||
{
|
||||
var imdbIdResults = new List<RemoteSearchResult>();
|
||||
for (var i = 0; i < findResult.TvResults.Count; i++)
|
||||
var imdbIdResults = new RemoteSearchResult[tvResults.Count];
|
||||
for (var i = 0; i < tvResults.Count; i++)
|
||||
{
|
||||
var remoteResult = MapSearchTvToRemoteSearchResult(findResult.TvResults[i]);
|
||||
var remoteResult = MapSearchTvToRemoteSearchResult(tvResults[i]);
|
||||
remoteResult.SetProviderId(MetadataProvider.Imdb, imdbId);
|
||||
imdbIdResults.Add(remoteResult);
|
||||
imdbIdResults[i] = remoteResult;
|
||||
}
|
||||
|
||||
return imdbIdResults;
|
||||
|
@ -88,14 +89,15 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
|
|||
.FindByExternalIdAsync(tvdbId, FindExternalSource.TvDb, searchInfo.MetadataLanguage, cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
if (findResult?.TvResults != null)
|
||||
var tvResults = findResult?.TvResults;
|
||||
if (tvResults != null)
|
||||
{
|
||||
var tvIdResults = new List<RemoteSearchResult>();
|
||||
for (var i = 0; i < findResult.TvResults.Count; i++)
|
||||
var tvIdResults = new RemoteSearchResult[tvResults.Count];
|
||||
for (var i = 0; i < tvResults.Count; i++)
|
||||
{
|
||||
var remoteResult = MapSearchTvToRemoteSearchResult(findResult.TvResults[i]);
|
||||
var remoteResult = MapSearchTvToRemoteSearchResult(tvResults[i]);
|
||||
remoteResult.SetProviderId(MetadataProvider.Tvdb, tvdbId);
|
||||
tvIdResults.Add(remoteResult);
|
||||
tvIdResults[i] = remoteResult;
|
||||
}
|
||||
|
||||
return tvIdResults;
|
||||
|
@ -105,10 +107,10 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
|
|||
var tvSearchResults = await _tmdbClientManager.SearchSeriesAsync(searchInfo.Name, searchInfo.MetadataLanguage, cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
var remoteResults = new List<RemoteSearchResult>();
|
||||
var remoteResults = new RemoteSearchResult[tvSearchResults.Count];
|
||||
for (var i = 0; i < tvSearchResults.Count; i++)
|
||||
{
|
||||
remoteResults.Add(MapSearchTvToRemoteSearchResult(tvSearchResults[i]));
|
||||
remoteResults[i] = MapSearchTvToRemoteSearchResult(tvSearchResults[i]);
|
||||
}
|
||||
|
||||
return remoteResults;
|
||||
|
@ -236,7 +238,11 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
|
|||
|
||||
private Series MapTvShowToSeries(TvShow seriesResult, string preferredCountryCode)
|
||||
{
|
||||
var series = new Series {Name = seriesResult.Name, OriginalTitle = seriesResult.OriginalName};
|
||||
var series = new Series
|
||||
{
|
||||
Name = seriesResult.Name,
|
||||
OriginalTitle = seriesResult.OriginalName
|
||||
};
|
||||
|
||||
series.SetProviderId(MetadataProvider.Tmdb, seriesResult.Id.ToString(CultureInfo.InvariantCulture));
|
||||
|
||||
|
@ -322,7 +328,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
|
|||
{
|
||||
if (TmdbUtils.IsTrailerType(video))
|
||||
{
|
||||
series.AddTrailerUrl($"http://www.youtube.com/watch?v={video.Key}");
|
||||
series.AddTrailerUrl("https://www.youtube.com/watch?v=" + video.Key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user