Esempio n. 1
0
        public async Task <MetadataResult <Movie> > GetMetadata(MovieInfo info, CancellationToken cancellationToken)
        {
            // Empty result
            var result = new MetadataResult <Movie>
            {
                HasMetadata = false,
                Item        = new Movie
                {
                    Name = info.Name
                }
            };

            var seriesId = info.ProviderIds.GetOrDefault(ProviderNames.AniDb);

            if (seriesId == null)
            {
                return(result);
            }

            var seriesInfo = new SeriesInfo();

            seriesInfo.ProviderIds.Add(ProviderNames.AniDb, seriesId);

            var seriesResult = await _seriesProvider.GetMetadata(seriesInfo, cancellationToken);

            if (seriesResult.HasMetadata)
            {
                result = new MetadataResult <Movie>
                {
                    HasMetadata = true,
                    Item        = new Movie
                    {
                        Name            = seriesResult.Item.Name,
                        Overview        = seriesResult.Item.Overview,
                        PremiereDate    = seriesResult.Item.PremiereDate,
                        ProductionYear  = seriesResult.Item.ProductionYear,
                        EndDate         = seriesResult.Item.EndDate,
                        CommunityRating = seriesResult.Item.CommunityRating,
                        Studios         = seriesResult.Item.Studios,
                        Genres          = seriesResult.Item.Genres,
                        ProviderIds     = seriesResult.Item.ProviderIds,
                    },
                    People = seriesResult.People,
                    Images = seriesResult.Images
                };
            }

            return(result);
        }
        public async Task <MetadataResult <Season> > GetMetadata(SeasonInfo info, CancellationToken cancellationToken)
        {
            var result = new MetadataResult <Season>
            {
                HasMetadata = true,
                Item        = new Season
                {
                    Name        = info.Name,
                    IndexNumber = info.IndexNumber
                }
            };

            var seriesId = info.ProviderIds.GetOrDefault(ProviderNames.AniDb);

            if (seriesId == null)
            {
                return(result);
            }

            var seriesInfo = new SeriesInfo();

            seriesInfo.ProviderIds.Add(ProviderNames.AniDb, seriesId);

            var seriesResult = await _seriesProvider.GetMetadata(seriesInfo, cancellationToken);

            if (seriesResult.HasMetadata)
            {
                result.Item.Name            = seriesResult.Item.Name;
                result.Item.Overview        = seriesResult.Item.Overview;
                result.Item.PremiereDate    = seriesResult.Item.PremiereDate;
                result.Item.EndDate         = seriesResult.Item.EndDate;
                result.Item.CommunityRating = seriesResult.Item.CommunityRating;
                result.Item.Studios         = seriesResult.Item.Studios;
                result.Item.Genres          = seriesResult.Item.Genres;
            }

            return(result);
        }