Beispiel #1
0
        public async Task <MetadataResult <Episode> > GetMetadata(EpisodeInfo searchInfo, CancellationToken cancellationToken)
        {
            var result = new MetadataResult <Episode>();

            if (TvMazeSeriesProvider.IsValidSeries(searchInfo.SeriesProviderIds) &&
                (searchInfo.IndexNumber.HasValue || searchInfo.PremiereDate.HasValue))
            {
                var seriesDataPath = await TvMazeSeriesProvider.Current.EnsureSeriesInfo(searchInfo.SeriesProviderIds, searchInfo.MetadataLanguage, cancellationToken).ConfigureAwait(false);

                try
                {
                    result = FetchEpisodeData(searchInfo, seriesDataPath, cancellationToken);
                }
                catch (FileNotFoundException)
                {
                    // Don't fail the provider because this will just keep on going and going.
                }
                catch (DirectoryNotFoundException)
                {
                    // Don't fail the provider because this will just keep on going and going.
                }
            }
            else
            {
                _logger.Debug("No series identity found for {0}", searchInfo.Name);
            }

            return(result);
        }
Beispiel #2
0
        public async Task <IEnumerable <RemoteSearchResult> > GetSearchResults(EpisodeInfo searchInfo, CancellationToken cancellationToken)
        {
            var list = new List <RemoteSearchResult>();

            // The search query must  provide an episode number
            if (!searchInfo.IndexNumber.HasValue)
            {
                return(list);
            }

            if (TvMazeSeriesProvider.IsValidSeries(searchInfo.SeriesProviderIds))
            {
                var seriesDataPath = await TvMazeSeriesProvider.Current.EnsureSeriesInfo(searchInfo.SeriesProviderIds, searchInfo.MetadataLanguage, cancellationToken).ConfigureAwait(false);

                try
                {
                    var metadataResult = FetchEpisodeData(searchInfo, seriesDataPath, cancellationToken);

                    if (metadataResult.HasMetadata)
                    {
                        var item = metadataResult.Item;

                        list.Add(new RemoteSearchResult
                        {
                            IndexNumber        = item.IndexNumber,
                            Name               = item.Name,
                            ParentIndexNumber  = item.ParentIndexNumber,
                            PremiereDate       = item.PremiereDate,
                            ProductionYear     = item.ProductionYear,
                            ProviderIds        = item.ProviderIds,
                            SearchProviderName = Name,
                            IndexNumberEnd     = item.IndexNumberEnd
                        });
                    }
                }
                catch (FileNotFoundException)
                {
                    // Don't fail the provider because this will just keep on going and going.
                }
                catch (DirectoryNotFoundException)
                {
                    // Don't fail the provider because this will just keep on going and going.
                }
            }

            return(list);
        }
Beispiel #3
0
        public bool HasChanged(IHasMetadata item, IDirectoryService directoryService)
        {
            // Only enable for virtual items
            if (item.LocationType != LocationType.Virtual)
            {
                return(false);
            }

            var episode = (Episode)item;
            var series  = episode.Series;

            if (series != null && TvMazeSeriesProvider.IsValidSeries(series.ProviderIds))
            {
                // Process images
                var seriesDataPath = TvMazeSeriesProvider.GetSeriesDataPath(_config.ApplicationPaths, series.ProviderIds);
                var seriesPath     = TvMazeSeriesProvider.Current.GetSeriesPath(seriesDataPath);

                return(_fileSystem.GetLastWriteTimeUtc(seriesPath) > item.DateLastRefreshed);
            }

            return(false);
        }
        public async Task <IEnumerable <RemoteImageInfo> > GetImages(IHasImages item, CancellationToken cancellationToken)
        {
            var season = (Season)item;
            var series = season.Series;


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

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

                if (!string.IsNullOrWhiteSpace(seriesDataPath))
                {
                    var seasonFileName = TvMazeSeriesProvider.Current.GetSeasonPath(seriesDataPath, seasonNumber);


                    try
                    {
                        var mazeSeason = _jsonSerializer.DeserializeFromFile <MazeSeason>(seasonFileName);
                        return(GetImages(mazeSeason));
                    }
                    catch (FileNotFoundException)
                    {
                        // No tv maze data yet. Don't blow up
                    }
                    catch (DirectoryNotFoundException)
                    {
                        // No tv maze data yet. Don't blow up
                    }
                }
            }

            return(new RemoteImageInfo[] { });
        }