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 <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);
        }
        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);
        }