Esempio n. 1
0
        protected async Task <ApiWrapperImageCollection <FanArtMovieThumb> > GetArtistFanArtAsync(PersonInfo person)
        {
            if (person == null || string.IsNullOrEmpty(person.MusicBrainzId))
            {
                return(null);
            }
            // Download all image information, filter later!
            FanArtArtistThumbs thumbs = await _fanArtTvHandler.GetArtistThumbsAsync(person.MusicBrainzId).ConfigureAwait(false);

            if (thumbs == null)
            {
                return(null);
            }
            ApiWrapperImageCollection <FanArtMovieThumb> images = new ApiWrapperImageCollection <FanArtMovieThumb>();

            images.Id = person.MusicBrainzId;
            if (thumbs.ArtistFanart != null)
            {
                images.Backdrops.AddRange(SortByLikes(thumbs.ArtistFanart));
            }
            if (thumbs.ArtistBanners != null)
            {
                images.Banners.AddRange(SortByLikes(thumbs.ArtistBanners));
            }
            if (thumbs.HDArtistLogos != null)
            {
                images.Logos.AddRange(SortByLikes(thumbs.HDArtistLogos));
            }
            if (thumbs.ArtistThumbnails != null)
            {
                images.Thumbnails.AddRange(SortByLikes(thumbs.ArtistThumbnails));
            }
            return(images);
        }
Esempio n. 2
0
        protected async Task <ApiWrapperImageCollection <TvdbBanner> > GetActorFanArtAsync(PersonInfo person, TvdbLanguage language)
        {
            if (person == null || person.TvdbId < 1)
            {
                return(null);
            }
            int seriesTvdbId;

            if (!_seriesToActorMap.GetMappedId(person.TvdbId.ToString(), out string seriesId) || !int.TryParse(seriesId, out seriesTvdbId))
            {
                return(null);
            }
            TvdbSeries seriesDetail = await _tvdbHandler.GetSeriesAsync(seriesTvdbId, language, false, true, true).ConfigureAwait(false);

            if (seriesDetail == null)
            {
                return(null);
            }
            TvdbActor actor = seriesDetail.TvdbActors.FirstOrDefault(a => a.Id == person.TvdbId);

            if (actor == null)
            {
                return(null);
            }
            ApiWrapperImageCollection <TvdbBanner> images = new ApiWrapperImageCollection <TvdbBanner>();

            images.Id = actor.Id.ToString();
            images.Thumbnails.AddRange(new TvdbBanner[] { actor.ActorImage });
            return(images);
        }
Esempio n. 3
0
        protected async Task <ApiWrapperImageCollection <FanArtMovieThumb> > GetAlbumFanArtAsync(AlbumInfo album)
        {
            if (album == null || string.IsNullOrEmpty(album.MusicBrainzDiscId))
            {
                return(null);
            }
            // Download all image information, filter later!
            FanArtAlbumDetails albumDetails = await _fanArtTvHandler.GetAlbumThumbsAsync(album.MusicBrainzGroupId).ConfigureAwait(false);

            if (albumDetails == null || albumDetails.Albums == null)
            {
                return(null);
            }
            FanArtAlbumThumbs thumbs;

            if (!albumDetails.Albums.TryGetValue(album.MusicBrainzDiscId, out thumbs))
            {
                return(null);
            }
            ApiWrapperImageCollection <FanArtMovieThumb> images = new ApiWrapperImageCollection <FanArtMovieThumb>();

            images.Id = album.MusicBrainzDiscId;
            if (thumbs.AlbumCovers != null)
            {
                images.Covers.AddRange(SortByLikes(thumbs.AlbumCovers));
            }
            if (thumbs.CDArts != null)
            {
                images.DiscArt.AddRange(SortByLikes(thumbs.CDArts));
            }
            return(images);
        }
Esempio n. 4
0
        protected async Task <ApiWrapperImageCollection <FanArtMovieThumb> > GetSeasonFanArtAsync(SeasonInfo season, string language)
        {
            if (season == null || season.SeriesTvdbId < 1 || !season.SeasonNumber.HasValue)
            {
                return(null);
            }
            int seasonNo = season.SeasonNumber.Value;
            // Download all image information, filter later!
            FanArtTVThumbs thumbs = await _fanArtTvHandler.GetSeriesThumbsAsync(season.SeriesTvdbId.ToString()).ConfigureAwait(false);

            if (thumbs == null)
            {
                return(null);
            }
            ApiWrapperImageCollection <FanArtMovieThumb> images = new ApiWrapperImageCollection <FanArtMovieThumb>();

            images.Id = season.SeriesTvdbId.ToString();
            if (thumbs.SeasonBanners != null)
            {
                images.Banners.AddRange(SortBySeasonNumberLanguageAndLikes(seasonNo, thumbs.SeasonBanners));
            }
            if (thumbs.SeasonPosters != null)
            {
                images.Posters.AddRange(SortBySeasonNumberLanguageAndLikes(seasonNo, thumbs.SeasonPosters));
            }
            if (thumbs.SeasonThumbnails != null)
            {
                images.Thumbnails.AddRange(SortBySeasonNumberLanguageAndLikes(seasonNo, thumbs.SeasonThumbnails));
            }
            return(images);
        }
        protected async Task <ApiWrapperImageCollection <string> > GetAlbumFanArtAsync(AlbumInfo album, string language)
        {
            if (album == null || album.AudioDbId < 1)
            {
                return(null);
            }
            AudioDbAlbum albumDetail = await _audioDbHandler.GetAlbumAsync(album.AudioDbId, language, false).ConfigureAwait(false);

            if (albumDetail == null)
            {
                return(null);
            }
            ApiWrapperImageCollection <string> images = new ApiWrapperImageCollection <string>();

            images.Id = album.AudioDbId.ToString();
            if (!string.IsNullOrEmpty(albumDetail.AlbumThumb))
            {
                images.Covers.Add(albumDetail.AlbumThumb);
            }
            if (!string.IsNullOrEmpty(albumDetail.AlbumCDart))
            {
                images.DiscArt.Add(albumDetail.AlbumCDart);
            }
            return(images);
        }
Esempio n. 6
0
        protected async Task <ApiWrapperImageCollection <FanArtMovieThumb> > GetMovieFanArtAsync(MovieInfo movie, string language)
        {
            if (movie == null || movie.MovieDbId < 1)
            {
                return(null);
            }
            // Download all image information, filter later!
            FanArtMovieThumbs thumbs = await _fanArtTvHandler.GetMovieThumbsAsync(movie.MovieDbId.ToString()).ConfigureAwait(false);

            if (thumbs == null)
            {
                return(null);
            }
            ApiWrapperImageCollection <FanArtMovieThumb> images = new ApiWrapperImageCollection <FanArtMovieThumb>();

            images.Id = movie.MovieDbId.ToString();
            if (thumbs.MovieFanArt != null)
            {
                images.Backdrops.AddRange(SortByLanguageAndLikes(thumbs.MovieFanArt));
            }
            if (thumbs.MovieBanners != null)
            {
                images.Banners.AddRange(SortByLanguageAndLikes(thumbs.MovieBanners));
            }
            if (thumbs.MoviePosters != null)
            {
                images.Posters.AddRange(SortByLanguageAndLikes(thumbs.MoviePosters));
            }
            if (thumbs.MovieCDArt != null)
            {
                images.DiscArt.AddRange(SortByLanguageAndLikes(thumbs.MovieCDArt));
            }
            if (thumbs.HDMovieClearArt != null)
            {
                images.ClearArt.AddRange(SortByLanguageAndLikes(thumbs.HDMovieClearArt));
            }
            if (thumbs.HDMovieLogos != null)
            {
                images.Logos.AddRange(SortByLanguageAndLikes(thumbs.HDMovieLogos));
            }
            if (thumbs.MovieThumbnails != null)
            {
                images.Thumbnails.AddRange(SortByLanguageAndLikes(thumbs.MovieThumbnails));
            }
            return(images);
        }
Esempio n. 7
0
        protected async Task <ApiWrapperImageCollection <TvMazeImageCollection> > GetSeriesFanArtAsync(SeriesInfo series)
        {
            if (series == null || series.TvMazeId < 1)
            {
                return(null);
            }
            TvMazeSeries seriesDetail = await _tvMazeHandler.GetSeriesAsync(series.TvMazeId, false).ConfigureAwait(false);

            if (seriesDetail == null)
            {
                return(null);
            }
            ApiWrapperImageCollection <TvMazeImageCollection> images = new ApiWrapperImageCollection <TvMazeImageCollection>();

            images.Id = series.TvMazeId.ToString();
            images.Posters.Add(seriesDetail.Images);
            return(images);
        }
Esempio n. 8
0
        protected async Task <ApiWrapperImageCollection <TvMazeImageCollection> > GetEpisodeFanArtAsync(EpisodeInfo episode)
        {
            if (episode == null || episode.SeriesTvMazeId < 1 || !episode.SeasonNumber.HasValue || episode.EpisodeNumbers.Count == 0)
            {
                return(null);
            }
            TvMazeEpisode episodeDetail = await _tvMazeHandler.GetSeriesEpisodeAsync(episode.SeriesTvMazeId, episode.SeasonNumber.Value, episode.FirstEpisodeNumber, false).ConfigureAwait(false);

            if (episodeDetail == null)
            {
                return(null);
            }
            ApiWrapperImageCollection <TvMazeImageCollection> images = new ApiWrapperImageCollection <TvMazeImageCollection>();

            images.Id = episode.SeriesTvMazeId.ToString();
            images.Thumbnails.Add(episodeDetail.Images);
            return(images);
        }
Esempio n. 9
0
        protected async Task <ApiWrapperImageCollection <TvMazeImageCollection> > GetCharactorFanArtAsync(CharacterInfo character)
        {
            if (character == null || character.TvMazeId < 1)
            {
                return(null);
            }
            TvMazePerson personDetail = await _tvMazeHandler.GetCharacterAsync(character.TvMazeId, false).ConfigureAwait(false);

            if (personDetail == null)
            {
                return(null);
            }
            ApiWrapperImageCollection <TvMazeImageCollection> images = new ApiWrapperImageCollection <TvMazeImageCollection>();

            images.Id = character.TvMazeId.ToString();
            images.Thumbnails.Add(personDetail.Images);
            return(images);
        }
Esempio n. 10
0
        protected async Task <ApiWrapperImageCollection <string> > GetMovieFanArtAsync(MovieInfo movie)
        {
            if (movie == null || string.IsNullOrEmpty(movie.ImdbId))
            {
                return(null);
            }
            SimApiMovie movieDetail = await _simApiHandler.GetMovieAsync(movie.ImdbId, false).ConfigureAwait(false);

            if (movieDetail == null || string.IsNullOrEmpty(movieDetail.PosterUrl))
            {
                return(null);
            }
            ApiWrapperImageCollection <string> images = new ApiWrapperImageCollection <string>();

            images.Id = movie.ImdbId;
            images.Posters.Add(movieDetail.PosterUrl);
            return(images);
        }
Esempio n. 11
0
        protected async Task <ApiWrapperImageCollection <string> > GetPersonFanArtAsync(PersonInfo person)
        {
            if (person == null || string.IsNullOrEmpty(person.ImdbId))
            {
                return(null);
            }
            SimApiPerson personDetail = await _simApiHandler.GetPersonAsync(person.ImdbId, false).ConfigureAwait(false);

            if (personDetail == null || string.IsNullOrEmpty(personDetail.ImageUrl))
            {
                return(null);
            }
            ApiWrapperImageCollection <string> images = new ApiWrapperImageCollection <string>();

            images.Id = person.ImdbId;
            images.Posters.Add(personDetail.ImageUrl);
            return(images);
        }
Esempio n. 12
0
        protected async Task <ApiWrapperImageCollection <TrackImage> > GetAlbumFanArtAsync(AlbumInfo album)
        {
            if (album == null || string.IsNullOrEmpty(album.MusicBrainzId))
            {
                return(null);
            }
            // Download all image information, filter later!
            TrackImageCollection albumImages = await _musicBrainzHandler.GetImagesAsync(album.MusicBrainzId).ConfigureAwait(false);

            if (albumImages == null)
            {
                return(null);
            }
            ApiWrapperImageCollection <TrackImage> images = new ApiWrapperImageCollection <TrackImage>();

            images.Id = album.MusicBrainzId;
            images.Covers.AddRange(albumImages.Images);
            return(images);
        }
Esempio n. 13
0
        protected async Task <ApiWrapperImageCollection <FanArtMovieThumb> > GetSeriesFanArtAsync(SeriesInfo series, string language)
        {
            if (series == null || series.TvdbId < 1)
            {
                return(null);
            }
            // Download all image information, filter later!
            FanArtTVThumbs thumbs = await _fanArtTvHandler.GetSeriesThumbsAsync(series.TvdbId.ToString()).ConfigureAwait(false);

            if (thumbs == null)
            {
                return(null);
            }
            ApiWrapperImageCollection <FanArtMovieThumb> images = new ApiWrapperImageCollection <FanArtMovieThumb>();

            images.Id = series.TvdbId.ToString();
            if (thumbs.SeriesFanArt != null)
            {
                images.Backdrops.AddRange(SortByLanguageAndLikes(thumbs.SeriesFanArt));
            }
            if (thumbs.SeriesBanners != null)
            {
                images.Banners.AddRange(SortByLanguageAndLikes(thumbs.SeriesBanners));
            }
            if (thumbs.SeriesPosters != null)
            {
                images.Posters.AddRange(SortByLanguageAndLikes(thumbs.SeriesPosters));
            }
            if (thumbs.HDSeriesClearArt != null)
            {
                images.ClearArt.AddRange(SortByLanguageAndLikes(thumbs.HDSeriesClearArt));
            }
            if (thumbs.HDSeriesLogos != null)
            {
                images.Logos.AddRange(SortByLanguageAndLikes(thumbs.HDSeriesLogos));
            }
            if (thumbs.SeriesThumbnails != null)
            {
                images.Thumbnails.AddRange(SortByLanguageAndLikes(thumbs.SeriesThumbnails));
            }
            return(images);
        }
Esempio n. 14
0
        protected async Task <ApiWrapperImageCollection <TvdbBanner> > GetSeriesFanArtAsync(SeriesInfo series, TvdbLanguage language)
        {
            if (series == null || series.TvdbId < 1)
            {
                return(null);
            }
            TvdbSeries seriesDetail = await _tvdbHandler.GetSeriesAsync(series.TvdbId, language, false, false, true).ConfigureAwait(false);

            if (seriesDetail == null)
            {
                return(null);
            }
            ApiWrapperImageCollection <TvdbBanner> images = new ApiWrapperImageCollection <TvdbBanner>();

            images.Id = series.TvdbId.ToString();
            images.Posters.AddRange(seriesDetail.PosterBanners.OrderBy(b => b.Language != language));
            images.Banners.AddRange(seriesDetail.SeriesBanners.OrderBy(b => b.Language != language));
            images.Backdrops.AddRange(seriesDetail.FanartBanners.OrderBy(b => b.Language != language));
            return(images);
        }
Esempio n. 15
0
        protected async Task <ApiWrapperImageCollection <string> > GetArtistFanArtAsync(PersonInfo person, string language)
        {
            if (person == null || person.AudioDbId < 1)
            {
                return(null);
            }
            AudioDbArtist artistDetail = await _audioDbHandler.GetArtistAsync(person.AudioDbId, language, false).ConfigureAwait(false);

            if (artistDetail == null)
            {
                return(null);
            }
            ApiWrapperImageCollection <string> images = new ApiWrapperImageCollection <string>();

            images.Id = person.AudioDbId.ToString();
            if (!string.IsNullOrEmpty(artistDetail.ArtistBanner))
            {
                images.Banners.Add(artistDetail.ArtistBanner);
            }
            if (!string.IsNullOrEmpty(artistDetail.ArtistFanart))
            {
                images.Backdrops.Add(artistDetail.ArtistFanart);
            }
            if (!string.IsNullOrEmpty(artistDetail.ArtistFanart2))
            {
                images.Backdrops.Add(artistDetail.ArtistFanart2);
            }
            if (!string.IsNullOrEmpty(artistDetail.ArtistFanart3))
            {
                images.Backdrops.Add(artistDetail.ArtistFanart3);
            }
            if (!string.IsNullOrEmpty(artistDetail.ArtistLogo))
            {
                images.Logos.Add(artistDetail.ArtistLogo);
            }
            if (!string.IsNullOrEmpty(artistDetail.ArtistThumb))
            {
                images.Thumbnails.Add(artistDetail.ArtistThumb);
            }
            return(images);
        }
Esempio n. 16
0
        protected async Task <ApiWrapperImageCollection <FanArtMovieThumb> > GetMusicLabelFanArtAsync(CompanyInfo company)
        {
            if (company == null || string.IsNullOrEmpty(company.MusicBrainzId))
            {
                return(null);
            }
            // Download all image information, filter later!
            FanArtLabelThumbs thumbs = await _fanArtTvHandler.GetLabelThumbsAsync(company.MusicBrainzId).ConfigureAwait(false);

            if (thumbs == null)
            {
                return(null);
            }
            ApiWrapperImageCollection <FanArtMovieThumb> images = new ApiWrapperImageCollection <FanArtMovieThumb>();

            images.Id = company.MusicBrainzId;
            if (thumbs.LabelLogos != null)
            {
                images.Logos.AddRange(SortByLikes(thumbs.LabelLogos));
            }
            return(images);
        }
        public override bool GetFanArt <T>(T infoObject, string language, string fanartMediaType, out ApiWrapperImageCollection <TrackImage> images)
        {
            images = new ApiWrapperImageCollection <TrackImage>();

            try
            {
                if (fanartMediaType == FanArtMediaTypes.Album)
                {
                    TrackInfo track = infoObject as TrackInfo;
                    AlbumInfo album = infoObject as AlbumInfo;
                    if (album == null && track != null)
                    {
                        album = track.CloneBasicInstance <AlbumInfo>();
                    }
                    if (album != null && !string.IsNullOrEmpty(album.MusicBrainzId))
                    {
                        // Download all image information, filter later!
                        TrackImageCollection albumImages = _musicBrainzHandler.GetImages(album.MusicBrainzId);
                        if (albumImages != null)
                        {
                            images.Id = album.MusicBrainzId;
                            images.Covers.AddRange(albumImages.Images);
                            return(true);
                        }
                    }
                }
                else
                {
                    return(true);
                }
            }
            catch (Exception ex)
            {
                ServiceRegistration.Get <ILogger>().Debug(GetType().Name + ": Exception downloading images", ex);
            }
            return(false);
        }
Esempio n. 18
0
        protected async Task <ApiWrapperImageCollection <TvdbBanner> > GetSeasonFanArtAsync(SeasonInfo season, TvdbLanguage language)
        {
            if (season == null || (season.SeriesTvdbId < 1 && string.IsNullOrEmpty(season.SeriesImdbId)) || !season.SeasonNumber.HasValue)
            {
                return(null);
            }
            TvdbSeries seriesDetail = null;

            if (season.SeriesTvdbId > 0)
            {
                seriesDetail = await _tvdbHandler.GetSeriesAsync(season.SeriesTvdbId, language, false, false, true).ConfigureAwait(false);
            }
            if (seriesDetail == null && !string.IsNullOrEmpty(season.SeriesImdbId))
            {
                TvdbSearchResult foundSeries = await _tvdbHandler.GetSeriesByRemoteIdAsync(ExternalId.ImdbId, season.SeriesImdbId).ConfigureAwait(false);

                if (foundSeries != null)
                {
                    seriesDetail = await _tvdbHandler.GetSeriesAsync(foundSeries.Id, language, false, false, true).ConfigureAwait(false);
                }
            }
            if (seriesDetail == null)
            {
                return(null);
            }
            ApiWrapperImageCollection <TvdbBanner> images = new ApiWrapperImageCollection <TvdbBanner>();

            images.Id = season.TvdbId.ToString();
            var seasonLookup = seriesDetail.SeasonBanners.Where(s => s.Season == season.SeasonNumber).ToLookup(s => string.Format("{0}_{1}", s.Season, s.BannerType), v => v);

            foreach (IGrouping <string, TvdbSeasonBanner> tvdbSeasonBanners in seasonLookup)
            {
                images.Banners.AddRange(seasonLookup[tvdbSeasonBanners.Key].Where(b => b.BannerPath.Contains("wide")).OrderBy(b => b.Language != language));
                images.Posters.AddRange(seasonLookup[tvdbSeasonBanners.Key].Where(b => !b.BannerPath.Contains("wide")).OrderBy(b => b.Language != language));
            }
            return(images);
        }
Esempio n. 19
0
        protected async Task <ApiWrapperImageCollection <TvdbBanner> > GetEpisodeFanArtAsync(EpisodeInfo episode, TvdbLanguage language)
        {
            if (episode == null || (episode.SeriesTvdbId < 1 && string.IsNullOrEmpty(episode.SeriesImdbId)) || !episode.SeasonNumber.HasValue || episode.EpisodeNumbers.Count == 0)
            {
                return(null);
            }
            TvdbSeries seriesDetail = null;

            if (episode.SeriesTvdbId > 0)
            {
                seriesDetail = await _tvdbHandler.GetSeriesAsync(episode.SeriesTvdbId, language, true, false, true).ConfigureAwait(false);
            }
            if (seriesDetail == null && !string.IsNullOrEmpty(episode.SeriesImdbId))
            {
                TvdbSearchResult foundSeries = await _tvdbHandler.GetSeriesByRemoteIdAsync(ExternalId.ImdbId, episode.SeriesImdbId).ConfigureAwait(false);

                if (foundSeries != null)
                {
                    seriesDetail = await _tvdbHandler.GetSeriesAsync(foundSeries.Id, language, true, false, true).ConfigureAwait(false);
                }
            }
            if (seriesDetail == null)
            {
                return(null);
            }
            TvdbEpisode episodeDetail = seriesDetail.Episodes.Find(e => e.SeasonNumber == episode.SeasonNumber.Value && e.EpisodeNumber == episode.FirstEpisodeNumber);

            if (episodeDetail == null)
            {
                return(null);
            }
            ApiWrapperImageCollection <TvdbBanner> images = new ApiWrapperImageCollection <TvdbBanner>();

            images.Id = episode.TvdbId.ToString();
            images.Thumbnails.AddRange(new TvdbBanner[] { episodeDetail.Banner });
            return(images);
        }
Esempio n. 20
0
        public override bool GetFanArt <T>(T infoObject, TvdbLanguage language, string fanartMediaType, out ApiWrapperImageCollection <TvdbBanner> images)
        {
            images = new ApiWrapperImageCollection <TvdbBanner>();

            try
            {
                try
                {
                    TvdbSeries seriesDetail = null;
                    language = language ?? PreferredLanguage;

                    if (fanartMediaType == FanArtMediaTypes.Series)
                    {
                        EpisodeInfo episode = infoObject as EpisodeInfo;
                        SeasonInfo  season  = infoObject as SeasonInfo;
                        SeriesInfo  series  = infoObject as SeriesInfo;
                        if (series == null && season != null)
                        {
                            series = season.CloneBasicInstance <SeriesInfo>();
                        }
                        if (series == null && episode != null)
                        {
                            series = episode.CloneBasicInstance <SeriesInfo>();
                        }
                        if (series != null && series.TvdbId > 0)
                        {
                            seriesDetail = _tvdbHandler.GetSeries(series.TvdbId, language, false, true, true);

                            if (seriesDetail != null)
                            {
                                images.Id = series.TvdbId.ToString();
                                images.Posters.AddRange(seriesDetail.PosterBanners.OrderBy(b => b.Language != language));
                                images.Banners.AddRange(seriesDetail.SeriesBanners.OrderBy(b => b.Language != language));
                                images.Backdrops.AddRange(seriesDetail.FanartBanners.OrderBy(b => b.Language != language));
                                return(true);
                            }
                        }
                    }
                    else if (fanartMediaType == FanArtMediaTypes.SeriesSeason)
                    {
                        EpisodeInfo episode = infoObject as EpisodeInfo;
                        SeasonInfo  season  = infoObject as SeasonInfo;
                        if (season == null && episode != null)
                        {
                            season = episode.CloneBasicInstance <SeasonInfo>();
                        }
                        if (season != null && season.SeriesTvdbId > 0 && season.SeasonNumber.HasValue)
                        {
                            seriesDetail = _tvdbHandler.GetSeries(season.SeriesTvdbId, language, false, false, true);

                            if (seriesDetail != null)
                            {
                                images.Id = season.TvdbId.ToString();

                                var seasonLookup = seriesDetail.SeasonBanners.Where(s => s.Season == season.SeasonNumber).ToLookup(s => string.Format("{0}_{1}", s.Season, s.BannerType), v => v);
                                foreach (IGrouping <string, TvdbSeasonBanner> tvdbSeasonBanners in seasonLookup)
                                {
                                    images.Banners.AddRange(seasonLookup[tvdbSeasonBanners.Key].Where(b => b.BannerPath.Contains("wide")).OrderBy(b => b.Language != language));
                                    images.Posters.AddRange(seasonLookup[tvdbSeasonBanners.Key].Where(b => !b.BannerPath.Contains("wide")).OrderBy(b => b.Language != language));
                                }
                                return(true);
                            }
                        }
                    }
                    else if (fanartMediaType == FanArtMediaTypes.Episode)
                    {
                        EpisodeInfo episode = infoObject as EpisodeInfo;
                        if (episode != null && episode.SeriesTvdbId > 0 && episode.SeasonNumber.HasValue && episode.EpisodeNumbers.Count > 0)
                        {
                            seriesDetail = _tvdbHandler.GetSeries(episode.SeriesTvdbId, language, true, false, true);

                            if (seriesDetail != null)
                            {
                                images.Id = episode.TvdbId.ToString();

                                TvdbEpisode episodeDetail = seriesDetail.Episodes.Find(e => e.SeasonNumber == episode.SeasonNumber.Value && e.EpisodeNumber == episode.FirstEpisodeNumber);
                                if (episodeDetail != null)
                                {
                                    images.Thumbnails.AddRange(new TvdbBanner[] { episodeDetail.Banner });
                                }
                                return(true);
                            }
                        }
                    }
                    else if (fanartMediaType == FanArtMediaTypes.Actor)
                    {
                        PersonInfo person   = infoObject as PersonInfo;
                        string     seriesId = null;
                        _seriesToActorMap.GetMappedId(person.TvdbId.ToString(), out seriesId);
                        int seriesTvdbId = 0;
                        if (int.TryParse(seriesId, out seriesTvdbId))
                        {
                            seriesDetail = _tvdbHandler.GetSeries(seriesTvdbId, language, false, true, true);
                            if (seriesDetail != null)
                            {
                                foreach (TvdbActor actor in seriesDetail.TvdbActors)
                                {
                                    if (actor.Id == person.TvdbId)
                                    {
                                        images.Id = actor.Id.ToString();
                                        images.Thumbnails.AddRange(new TvdbBanner[] { actor.ActorImage });
                                        return(true);
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        return(true);
                    }
                }
                catch (Exception ex)
                {
                    ServiceRegistration.Get <ILogger>().Error("TvDbWrapper: Error getting fan art for scope {0}", ex, fanartMediaType);
                }
            }
            catch (Exception ex)
            {
                ServiceRegistration.Get <ILogger>().Debug(GetType().Name + ": Exception downloading images", ex);
            }
            return(false);
        }
        public override bool GetFanArt <T>(T infoObject, string language, string fanartMediaType, out ApiWrapperImageCollection <FanArtMovieThumb> images)
        {
            images = new ApiWrapperImageCollection <FanArtMovieThumb>();

            try
            {
                if (fanartMediaType == FanArtMediaTypes.Movie)
                {
                    FanArtMovieThumbs imgs  = null;
                    MovieInfo         movie = infoObject as MovieInfo;
                    if (movie != null && movie.MovieDbId > 0)
                    {
                        // Download all image information, filter later!
                        imgs = _fanArtTvHandler.GetMovieThumbs(movie.MovieDbId.ToString());
                    }

                    if (imgs != null)
                    {
                        images.Id = movie.MovieDbId.ToString();
                        if (imgs.MovieFanArt != null)
                        {
                            images.Backdrops.AddRange(imgs.MovieFanArt.OrderBy(b => string.IsNullOrEmpty(b.Language)).ThenByDescending(b => b.Likes).ToList());
                        }
                        if (imgs.MovieBanners != null)
                        {
                            images.Banners.AddRange(imgs.MovieBanners.OrderBy(b => string.IsNullOrEmpty(b.Language)).ThenByDescending(b => b.Likes).ToList());
                        }
                        if (imgs.MoviePosters != null)
                        {
                            images.Posters.AddRange(imgs.MoviePosters.OrderBy(b => string.IsNullOrEmpty(b.Language)).ThenByDescending(b => b.Likes).ToList());
                        }
                        if (imgs.MovieCDArt != null)
                        {
                            images.DiscArt.AddRange(imgs.MovieCDArt.OrderBy(b => string.IsNullOrEmpty(b.Language)).ThenByDescending(b => b.Likes).ToList());
                        }
                        if (imgs.HDMovieClearArt != null)
                        {
                            images.ClearArt.AddRange(imgs.HDMovieClearArt.OrderBy(b => string.IsNullOrEmpty(b.Language)).ThenByDescending(b => b.Likes).ToList());
                        }
                        if (imgs.HDMovieLogos != null)
                        {
                            images.Logos.AddRange(imgs.HDMovieLogos.OrderBy(b => string.IsNullOrEmpty(b.Language)).ThenByDescending(b => b.Likes).ToList());
                        }
                        if (imgs.MovieThumbnails != null)
                        {
                            images.Thumbnails.AddRange(imgs.MovieThumbnails.OrderBy(b => string.IsNullOrEmpty(b.Language)).ThenByDescending(b => b.Likes).ToList());
                        }
                        return(true);
                    }
                }
                else if (fanartMediaType == FanArtMediaTypes.Series)
                {
                    FanArtTVThumbs imgs    = null;
                    EpisodeInfo    episode = infoObject as EpisodeInfo;
                    SeasonInfo     season  = infoObject as SeasonInfo;
                    SeriesInfo     series  = infoObject as SeriesInfo;
                    if (series == null && season != null)
                    {
                        series = season.CloneBasicInstance <SeriesInfo>();
                    }
                    if (series == null && episode != null)
                    {
                        series = episode.CloneBasicInstance <SeriesInfo>();
                    }
                    if (series != null && series.TvdbId > 0)
                    {
                        // Download all image information, filter later!
                        imgs = _fanArtTvHandler.GetSeriesThumbs(series.TvdbId.ToString());
                    }

                    if (imgs != null)
                    {
                        images.Id = series.TvdbId.ToString();
                        if (imgs.SeriesFanArt != null)
                        {
                            images.Backdrops.AddRange(imgs.SeriesFanArt.OrderBy(b => string.IsNullOrEmpty(b.Language)).ThenByDescending(b => b.Likes).ToList());
                        }
                        if (imgs.SeriesBanners != null)
                        {
                            images.Banners.AddRange(imgs.SeriesBanners.OrderBy(b => string.IsNullOrEmpty(b.Language)).ThenByDescending(b => b.Likes).ToList());
                        }
                        if (imgs.SeriesPosters != null)
                        {
                            images.Posters.AddRange(imgs.SeriesPosters.OrderBy(b => string.IsNullOrEmpty(b.Language)).ThenByDescending(b => b.Likes).ToList());
                        }
                        if (imgs.HDSeriesClearArt != null)
                        {
                            images.ClearArt.AddRange(imgs.HDSeriesClearArt.OrderBy(b => string.IsNullOrEmpty(b.Language)).ThenByDescending(b => b.Likes).ToList());
                        }
                        if (imgs.HDSeriesLogos != null)
                        {
                            images.Logos.AddRange(imgs.HDSeriesLogos.OrderBy(b => string.IsNullOrEmpty(b.Language)).ThenByDescending(b => b.Likes).ToList());
                        }
                        if (imgs.SeriesThumbnails != null)
                        {
                            images.Thumbnails.AddRange(imgs.SeriesThumbnails.OrderBy(b => string.IsNullOrEmpty(b.Language)).ThenByDescending(b => b.Likes).ToList());
                        }
                        return(true);
                    }
                }
                else if (fanartMediaType == FanArtMediaTypes.SeriesSeason)
                {
                    FanArtTVThumbs imgs     = null;
                    int            seasonNo = 0;
                    EpisodeInfo    episode  = infoObject as EpisodeInfo;
                    SeasonInfo     season   = infoObject as SeasonInfo;
                    if (season == null && episode != null)
                    {
                        season = episode.CloneBasicInstance <SeasonInfo>();
                    }
                    if (season != null && season.SeriesTvdbId > 0 && season.SeasonNumber.HasValue)
                    {
                        // Download all image information, filter later!
                        imgs     = _fanArtTvHandler.GetSeriesThumbs(season.SeriesTvdbId.ToString());
                        seasonNo = season.SeasonNumber.Value;
                    }

                    if (imgs != null)
                    {
                        images.Id = season.SeriesTvdbId.ToString();
                        if (imgs.SeasonBanners != null)
                        {
                            images.Banners.AddRange(imgs.SeasonBanners.FindAll(b => !b.Season.HasValue || b.Season == seasonNo).
                                                    OrderBy(b => string.IsNullOrEmpty(b.Language)).ThenByDescending(b => b.Likes).ToList());
                        }
                        if (imgs.SeasonPosters != null)
                        {
                            images.Posters.AddRange(imgs.SeasonPosters.FindAll(b => !b.Season.HasValue || b.Season == seasonNo).
                                                    OrderBy(b => string.IsNullOrEmpty(b.Language)).ThenByDescending(b => b.Likes).ToList());
                        }
                        if (imgs.SeasonThumbnails != null)
                        {
                            images.Thumbnails.AddRange(imgs.SeasonThumbnails.FindAll(b => !b.Season.HasValue || b.Season == seasonNo).
                                                       OrderBy(b => string.IsNullOrEmpty(b.Language)).ThenByDescending(b => b.Likes).ToList());
                        }
                        return(true);
                    }
                }
                else if (fanartMediaType == FanArtMediaTypes.Artist)
                {
                    FanArtArtistThumbs imgs   = null;
                    PersonInfo         person = infoObject as PersonInfo;
                    if (person != null && !string.IsNullOrEmpty(person.MusicBrainzId))
                    {
                        // Download all image information, filter later!
                        imgs = _fanArtTvHandler.GetArtistThumbs(person.MusicBrainzId);
                    }

                    if (imgs != null)
                    {
                        images.Id = person.MusicBrainzId;
                        if (imgs.ArtistFanart != null)
                        {
                            images.Backdrops.AddRange(imgs.ArtistFanart.OrderByDescending(b => b.Likes).Select(b => new FanArtMovieThumb(b)).ToList());
                        }
                        if (imgs.ArtistBanners != null)
                        {
                            images.Banners.AddRange(imgs.ArtistBanners.OrderByDescending(b => b.Likes).Select(b => new FanArtMovieThumb(b)).ToList());
                        }
                        if (imgs.HDArtistLogos != null)
                        {
                            images.Logos.AddRange(imgs.HDArtistLogos.OrderByDescending(b => b.Likes).Select(b => new FanArtMovieThumb(b)).ToList());
                        }
                        if (imgs.ArtistThumbnails != null)
                        {
                            images.Thumbnails.AddRange(imgs.ArtistThumbnails.OrderByDescending(b => b.Likes).Select(b => new FanArtMovieThumb(b)).ToList());
                        }
                        return(true);
                    }
                }
                else if (fanartMediaType == FanArtMediaTypes.MusicLabel)
                {
                    FanArtLabelThumbs imgs    = null;
                    CompanyInfo       company = infoObject as CompanyInfo;
                    if (company != null && !string.IsNullOrEmpty(company.MusicBrainzId))
                    {
                        // Download all image information, filter later!
                        imgs = _fanArtTvHandler.GetLabelThumbs(company.MusicBrainzId);
                    }

                    if (imgs != null)
                    {
                        images.Id = company.MusicBrainzId;
                        if (imgs.LabelLogos != null)
                        {
                            images.Logos.AddRange(imgs.LabelLogos.OrderByDescending(b => b.Likes).Select(b => new FanArtMovieThumb(b)).ToList());
                        }
                        return(true);
                    }
                }
                else if (fanartMediaType == FanArtMediaTypes.Album)
                {
                    FanArtAlbumDetails imgs    = null;
                    string             albumId = null;
                    TrackInfo          track   = infoObject as TrackInfo;
                    AlbumInfo          album   = infoObject as AlbumInfo;
                    if (album == null && track != null)
                    {
                        album = track.CloneBasicInstance <AlbumInfo>();
                    }
                    if (album != null && !string.IsNullOrEmpty(album.MusicBrainzGroupId))
                    {
                        // Download all image information, filter later!
                        imgs    = _fanArtTvHandler.GetAlbumThumbs(album.MusicBrainzGroupId);
                        albumId = album.MusicBrainzGroupId;
                    }

                    if (imgs != null)
                    {
                        images.Id = albumId;
                        if (imgs.Albums != null && imgs.Albums.ContainsKey(albumId) && imgs.Albums[albumId].AlbumCovers != null)
                        {
                            images.Covers.AddRange(imgs.Albums[albumId].AlbumCovers.OrderByDescending(b => b.Likes).Select(b => new FanArtMovieThumb(b)).ToList());
                        }
                        if (imgs.Albums != null && imgs.Albums.ContainsKey(albumId) && imgs.Albums[albumId].CDArts != null)
                        {
                            images.DiscArt.AddRange(imgs.Albums[albumId].CDArts.OrderByDescending(b => b.Likes).Select(b => new FanArtMovieThumb(b)).ToList());
                        }
                        return(true);
                    }
                }
                else
                {
                    return(true);
                }
            }
            catch (Exception ex)
            {
                ServiceRegistration.Get <ILogger>().Debug(GetType().Name + ": Exception downloading images", ex);
            }
            return(false);
        }
Esempio n. 22
0
        public override bool GetFanArt <T>(T infoObject, string language, string fanartMediaType, out ApiWrapperImageCollection <TvMazeImageCollection> images)
        {
            images = new ApiWrapperImageCollection <TvMazeImageCollection>();

            try
            {
                if (fanartMediaType == FanArtMediaTypes.Series)
                {
                    EpisodeInfo episode = infoObject as EpisodeInfo;
                    SeasonInfo  season  = infoObject as SeasonInfo;
                    SeriesInfo  series  = infoObject as SeriesInfo;
                    if (series == null && season != null)
                    {
                        series = season.CloneBasicInstance <SeriesInfo>();
                    }
                    if (series == null && episode != null)
                    {
                        series = episode.CloneBasicInstance <SeriesInfo>();
                    }
                    if (series != null && series.TvMazeId > 0)
                    {
                        // Download all image information, filter later!
                        TvMazeSeries seriesDetail = _tvMazeHandler.GetSeries(series.TvMazeId, false);
                        if (seriesDetail != null)
                        {
                            images.Id = series.TvMazeId.ToString();
                            images.Posters.Add(seriesDetail.Images);
                            return(true);
                        }
                    }
                }
                else if (fanartMediaType == FanArtMediaTypes.Episode)
                {
                    EpisodeInfo episode = infoObject as EpisodeInfo;
                    if (episode != null && episode.SeriesTvMazeId > 0 && episode.SeasonNumber.HasValue && episode.EpisodeNumbers.Count > 0)
                    {
                        // Download all image information, filter later!
                        TvMazeEpisode episodeDetail = _tvMazeHandler.GetSeriesEpisode(episode.SeriesTvMazeId, episode.SeasonNumber.Value, episode.FirstEpisodeNumber, false);
                        if (episodeDetail != null)
                        {
                            images.Id = episode.SeriesTvMazeId.ToString();
                            images.Thumbnails.Add(episodeDetail.Images);
                            return(true);
                        }
                    }
                }
                else if (fanartMediaType == FanArtMediaTypes.Actor)
                {
                    PersonInfo person = infoObject as PersonInfo;
                    if (person != null && person.TvMazeId > 0)
                    {
                        // Download all image information, filter later!
                        TvMazePerson personDetail = _tvMazeHandler.GetPerson(person.TvMazeId, false);
                        if (personDetail != null)
                        {
                            images.Id = person.TvMazeId.ToString();
                            images.Thumbnails.Add(personDetail.Images);
                            return(true);
                        }
                    }
                }
                else if (fanartMediaType == FanArtMediaTypes.Character)
                {
                    CharacterInfo character = infoObject as CharacterInfo;
                    if (character != null && character.TvMazeId > 0)
                    {
                        // Download all image information, filter later!
                        TvMazePerson personDetail = _tvMazeHandler.GetCharacter(character.TvMazeId, false);
                        if (personDetail != null)
                        {
                            images.Id = character.TvMazeId.ToString();
                            images.Thumbnails.Add(personDetail.Images);
                            return(true);
                        }
                    }
                }
                else
                {
                    return(true);
                }
            }
            catch (Exception ex)
            {
                ServiceRegistration.Get <ILogger>().Debug(GetType().Name + ": Exception downloading images", ex);
            }
            return(false);
        }
        public override bool GetFanArt <T>(T infoObject, string language, string fanartMediaType, out ApiWrapperImageCollection <string> images)
        {
            images = new ApiWrapperImageCollection <string>();

            try
            {
                if (fanartMediaType == FanArtMediaTypes.Album)
                {
                    TrackInfo track = infoObject as TrackInfo;
                    AlbumInfo album = infoObject as AlbumInfo;
                    if (album == null && track != null)
                    {
                        album = track.CloneBasicInstance <AlbumInfo>();
                    }
                    if (album != null && album.AudioDbId > 0)
                    {
                        AudioDbAlbum albumDetail = _audioDbHandler.GetAlbum(album.AudioDbId, language, false);
                        if (albumDetail != null)
                        {
                            images.Id = album.AudioDbId.ToString();
                            if (!string.IsNullOrEmpty(albumDetail.AlbumThumb))
                            {
                                images.Covers.Add(albumDetail.AlbumThumb);
                            }
                            if (!string.IsNullOrEmpty(albumDetail.AlbumCDart))
                            {
                                images.DiscArt.Add(albumDetail.AlbumCDart);
                            }
                            return(true);
                        }
                    }
                }
                else if (fanartMediaType == FanArtMediaTypes.Artist)
                {
                    PersonInfo person = infoObject as PersonInfo;
                    if (person != null && person.AudioDbId > 0)
                    {
                        AudioDbArtist artistDetail = _audioDbHandler.GetArtist(person.AudioDbId, language, false);
                        if (artistDetail != null)
                        {
                            images.Id = person.AudioDbId.ToString();
                            if (!string.IsNullOrEmpty(artistDetail.ArtistBanner))
                            {
                                images.Banners.Add(artistDetail.ArtistBanner);
                            }
                            if (!string.IsNullOrEmpty(artistDetail.ArtistFanart))
                            {
                                images.Backdrops.Add(artistDetail.ArtistFanart);
                            }
                            if (!string.IsNullOrEmpty(artistDetail.ArtistFanart2))
                            {
                                images.Backdrops.Add(artistDetail.ArtistFanart2);
                            }
                            if (!string.IsNullOrEmpty(artistDetail.ArtistFanart3))
                            {
                                images.Backdrops.Add(artistDetail.ArtistFanart3);
                            }
                            if (!string.IsNullOrEmpty(artistDetail.ArtistLogo))
                            {
                                images.Logos.Add(artistDetail.ArtistLogo);
                            }
                            if (!string.IsNullOrEmpty(artistDetail.ArtistThumb))
                            {
                                images.Thumbnails.Add(artistDetail.ArtistThumb);
                            }
                            return(true);
                        }
                    }
                }
                else
                {
                    return(true);
                }
            }
            catch (Exception ex)
            {
                ServiceRegistration.Get <ILogger>().Debug(GetType().Name + ": Exception downloading images", ex);
            }
            return(false);
        }