private IEnumerable <RemoteImageInfo> GetImages(MovieDbBoxSetProvider.RootObject obj, string language, string baseUrl) { var list = new List <RemoteImageInfo>(); var images = obj.images ?? new MovieDbBoxSetProvider.Images(); list.AddRange(GetPosters(images).Select(i => new RemoteImageInfo { Url = baseUrl + i.file_path, CommunityRating = i.vote_average, VoteCount = i.vote_count, Width = i.width, Height = i.height, Language = MovieDbProvider.AdjustImageLanguage(i.iso_639_1, language), ProviderName = Name, Type = ImageType.Primary, RatingType = RatingType.Score })); list.AddRange(GetBackdrops(images).Select(i => new RemoteImageInfo { Url = baseUrl + i.file_path, CommunityRating = i.vote_average, VoteCount = i.vote_count, Width = i.width, Height = i.height, ProviderName = Name, Type = ImageType.Backdrop, RatingType = RatingType.Score })); var isLanguageEn = string.Equals(language, "en", StringComparison.OrdinalIgnoreCase); return(list.OrderByDescending(i => { if (string.Equals(language, i.Language, StringComparison.OrdinalIgnoreCase)) { return 3; } if (!isLanguageEn) { if (string.Equals("en", i.Language, StringComparison.OrdinalIgnoreCase)) { return 2; } } if (string.IsNullOrEmpty(i.Language)) { return isLanguageEn ? 3 : 2; } return 0; }) .ThenByDescending(i => i.CommunityRating ?? 0) .ThenByDescending(i => i.VoteCount ?? 0) .ToList()); }
public async Task <IEnumerable <RemoteImageInfo> > GetImages(IHasMetadata item, CancellationToken cancellationToken) { var episode = (Controller.Entities.TV.Episode)item; var series = episode.Series; var seriesId = series != null?series.GetProviderId(MetadataProviders.Tmdb) : null; var list = new List <RemoteImageInfo>(); if (string.IsNullOrEmpty(seriesId)) { return(list); } var seasonNumber = episode.ParentIndexNumber; var episodeNumber = episode.IndexNumber; if (!seasonNumber.HasValue || !episodeNumber.HasValue) { return(list); } var language = item.GetPreferredMetadataLanguage(); var response = await GetEpisodeInfo(seriesId, seasonNumber.Value, episodeNumber.Value, language, cancellationToken).ConfigureAwait(false); var tmdbSettings = await MovieDbProvider.Current.GetTmdbSettings(cancellationToken).ConfigureAwait(false); var tmdbImageUrl = tmdbSettings.images.secure_base_url + "original"; list.AddRange(GetPosters(response.images).Select(i => new RemoteImageInfo { Url = tmdbImageUrl + i.file_path, CommunityRating = i.vote_average, VoteCount = i.vote_count, Width = i.width, Height = i.height, Language = MovieDbProvider.AdjustImageLanguage(i.iso_639_1, language), ProviderName = Name, Type = ImageType.Primary, RatingType = RatingType.Score })); var isLanguageEn = string.Equals(language, "en", StringComparison.OrdinalIgnoreCase); return(list.OrderByDescending(i => { if (string.Equals(language, i.Language, StringComparison.OrdinalIgnoreCase)) { return 3; } if (!isLanguageEn) { if (string.Equals("en", i.Language, StringComparison.OrdinalIgnoreCase)) { return 2; } } if (string.IsNullOrEmpty(i.Language)) { return isLanguageEn ? 3 : 2; } return 0; }) .ThenByDescending(i => i.CommunityRating ?? 0) .ThenByDescending(i => i.VoteCount ?? 0)); }
public async Task <IEnumerable <RemoteImageInfo> > GetImages(BaseItem item, CancellationToken cancellationToken) { var list = new List <RemoteImageInfo>(); var results = await FetchImages(item, null, _jsonSerializer, cancellationToken).ConfigureAwait(false); if (results == null) { return(list); } var tmdbSettings = await MovieDbProvider.Current.GetTmdbSettings(cancellationToken).ConfigureAwait(false); var tmdbImageUrl = tmdbSettings.images.GetImageUrl("original"); var language = item.GetPreferredMetadataLanguage(); list.AddRange(GetPosters(results).Select(i => new RemoteImageInfo { Url = tmdbImageUrl + i.file_path, CommunityRating = i.vote_average, VoteCount = i.vote_count, Width = i.width, Height = i.height, Language = MovieDbProvider.AdjustImageLanguage(i.iso_639_1, language), ProviderName = Name, Type = ImageType.Primary, RatingType = RatingType.Score })); list.AddRange(GetBackdrops(results).Select(i => new RemoteImageInfo { Url = tmdbImageUrl + i.file_path, CommunityRating = i.vote_average, VoteCount = i.vote_count, Width = i.width, Height = i.height, ProviderName = Name, Type = ImageType.Backdrop, RatingType = RatingType.Score })); var isLanguageEn = string.Equals(language, "en", StringComparison.OrdinalIgnoreCase); return(list.OrderByDescending(i => { if (string.Equals(language, i.Language, StringComparison.OrdinalIgnoreCase)) { return 3; } if (!isLanguageEn) { if (string.Equals("en", i.Language, StringComparison.OrdinalIgnoreCase)) { return 2; } } if (string.IsNullOrEmpty(i.Language)) { return isLanguageEn ? 3 : 2; } return 0; }) .ThenByDescending(i => i.CommunityRating ?? 0) .ThenByDescending(i => i.VoteCount ?? 0)); }