コード例 #1
0
        private IEnumerable <RemoteImageInfo> GetImages(CollectionResult obj, string language, string baseUrl)
        {
            var list = new List <RemoteImageInfo>();

            var images = obj.Images ?? new CollectionImages();

            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        = TmdbMovieProvider.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));
        }
コード例 #2
0
        public async Task <IEnumerable <RemoteImageInfo> > GetImages(BaseItem item, CancellationToken cancellationToken)
        {
            var list = new List <RemoteImageInfo>();

            var results = await FetchImages(item, null, cancellationToken).ConfigureAwait(false);

            if (results == null)
            {
                return(list);
            }

            var tmdbSettings = await TmdbMovieProvider.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        = TmdbMovieProvider.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));
        }
コード例 #3
0
        public async Task <IEnumerable <RemoteImageInfo> > GetImages(BaseItem item, CancellationToken cancellationToken)
        {
            var episode = (Controller.Entities.TV.Episode)item;
            var series  = episode.Series;

            var seriesId = series != null?series.GetProviderId(MetadataProvider.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 TmdbMovieProvider.Current.GetTmdbSettings(cancellationToken).ConfigureAwait(false);

            var tmdbImageUrl = tmdbSettings.images.GetImageUrl("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        = TmdbMovieProvider.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));
        }
コード例 #4
0
        public async Task <IEnumerable <RemoteImageInfo> > GetImages(BaseItem item, CancellationToken cancellationToken)
        {
            var season = (Season)item;
            var series = season.Series;

            var seriesId = series?.GetProviderId(MetadataProvider.Tmdb);

            if (string.IsNullOrEmpty(seriesId))
            {
                return(Enumerable.Empty <RemoteImageInfo>());
            }

            var seasonNumber = season.IndexNumber;

            if (!seasonNumber.HasValue)
            {
                return(Enumerable.Empty <RemoteImageInfo>());
            }

            var language = item.GetPreferredMetadataLanguage();

            var results = await FetchImages(season, seriesId, language, cancellationToken).ConfigureAwait(false);

            var tmdbSettings = await TmdbMovieProvider.Current.GetTmdbSettings(cancellationToken).ConfigureAwait(false);

            var tmdbImageUrl = tmdbSettings.images.GetImageUrl("original");

            var list = 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        = TmdbMovieProvider.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));
        }