Esempio n. 1
0
        public async Task <IEnumerable <RemoteImageInfo> > GetImages(IHasImages item, CancellationToken cancellationToken)
        {
            var season = (Season)item;
            var series = season.Series;

            if (series != null && season.IndexNumber.HasValue && TvdbSeriesProvider.IsValidSeries(series.ProviderIds))
            {
                var seriesProviderIds = series.ProviderIds;
                var seasonNumber      = season.IndexNumber.Value;

                var identity = TvdbSeasonIdentityProvider.ParseIdentity(season.GetProviderId(TvdbSeasonIdentityProvider.FullIdKey));
                if (identity == null)
                {
                    identity = new TvdbSeasonIdentity(series.GetProviderId(MetadataProviders.Tvdb), seasonNumber);
                }

                if (identity != null)
                {
                    var id = identity.Value;
                    seasonNumber = AdjustForSeriesOffset(series, id.Index);

                    seriesProviderIds = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase);
                    seriesProviderIds[MetadataProviders.Tvdb.ToString()] = id.SeriesId;
                }

                var seriesDataPath = await TvdbSeriesProvider.Current.EnsureSeriesInfo(seriesProviderIds, series.GetPreferredMetadataLanguage(), cancellationToken).ConfigureAwait(false);

                if (!string.IsNullOrWhiteSpace(seriesDataPath))
                {
                    var path = Path.Combine(seriesDataPath, "banners.xml");

                    try
                    {
                        return(GetImages(path, item.GetPreferredMetadataLanguage(), seasonNumber, cancellationToken));
                    }
                    catch (FileNotFoundException)
                    {
                        // No tvdb data yet. Don't blow up
                    }
                    catch (DirectoryNotFoundException)
                    {
                        // No tvdb data yet. Don't blow up
                    }
                }
            }

            return(new RemoteImageInfo[] { });
        }
Esempio n. 2
0
 public TvdbSeasonIdentity(string id)
     : this()
 {
     this = TvdbSeasonIdentityProvider.ParseIdentity(id).Value;
 }