public async Task <IEnumerable <RemoteSearchResult> > GetSearchResults(EpisodeInfo searchInfo, CancellationToken cancellationToken)
        {
            var list = new List <RemoteSearchResult>();

            var id = AniDbEpisodeIdentity.Parse(searchInfo.ProviderIds.GetOrDefault(ProviderNames.AniDb));

            if (id == null)
            {
                //var episodeIdentifier = new AnidbEpisodeIdentityProvider();
                //await episodeIdentifier.Identify(searchInfo);

                //var converter = new AnidbTvdbEpisodeConverter();
                //await converter.Convert(searchInfo);

                //id = AnidbEpisodeIdentity.Parse(searchInfo.ProviderIds.GetOrDefault(ProviderNames.AniDb));
            }

            if (id == null)
            {
                return(list);
            }

            await AniDbSeriesProvider.GetSeriesData(
                _configurationManager.ApplicationPaths,
                _httpClient,
                id.Value.SeriesId,
                cancellationToken).ConfigureAwait(false);

            try
            {
                var metadataResult = await GetMetadata(searchInfo, cancellationToken).ConfigureAwait(false);

                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);
        }
        public Task <IEnumerable <RemoteImageInfo> > GetImages(BaseItem item, CancellationToken cancellationToken)
        {
            var infos = new List <RemoteImageInfo>();

            var person = AniDbSeriesProvider.GetPersonInfo(_paths.CachePath, item.Name);

            if (person != null)
            {
                infos.Add(new RemoteImageInfo
                {
                    Url          = person.Image,
                    Type         = ImageType.Primary,
                    ProviderName = Name
                });
            }

            return(Task.FromResult <IEnumerable <RemoteImageInfo> >(infos));
        }
        public Task <MetadataResult <Person> > GetMetadata(PersonLookupInfo info, CancellationToken cancellationToken)
        {
            var result = new MetadataResult <Person>();

            if (!string.IsNullOrEmpty(info.ProviderIds.GetOrDefault(ProviderNames.AniDb)))
            {
                return(Task.FromResult(result));
            }

            var person = AniDbSeriesProvider.GetPersonInfo(_paths.CachePath, info.Name);

            if (!string.IsNullOrEmpty(person?.Id))
            {
                result.Item        = new Person();
                result.HasMetadata = true;

                result.Item.SetProviderId(ProviderNames.AniDb, person.Id);
            }

            return(Task.FromResult(result));
        }
        public async Task <IEnumerable <RemoteImageInfo> > GetImages(string aniDbId, CancellationToken cancellationToken)
        {
            var list = new List <RemoteImageInfo>();

            if (!string.IsNullOrEmpty(aniDbId))
            {
                var seriesDataPath = await AniDbSeriesProvider.GetSeriesData(_appPaths, _httpClient, aniDbId, cancellationToken);

                var imageUrl = await FindImageUrl(seriesDataPath).ConfigureAwait(false);

                if (!string.IsNullOrEmpty(imageUrl))
                {
                    list.Add(new RemoteImageInfo
                    {
                        ProviderName = Name,
                        Url          = imageUrl
                    });
                }
            }

            return(list);
        }
        private async Task <string> FindSeriesFolder(string seriesId, CancellationToken cancellationToken)
        {
            var seriesDataPath = await AniDbSeriesProvider.GetSeriesData(_configurationManager.ApplicationPaths, _httpClient, seriesId, cancellationToken).ConfigureAwait(false);

            return(Path.GetDirectoryName(seriesDataPath));
        }
示例#6
0
 public AniDbMovieProvider(IApplicationPaths appPaths, IHttpClient httpClient, ILogger <AniDbMovieProvider> logger)
 {
     _seriesProvider = new AniDbSeriesProvider(appPaths, httpClient);
     _logger         = logger;
 }
 public AniDbSeasonProvider(IHttpClient httpClient, IApplicationPaths appPaths)
 {
     _seriesProvider = new AniDbSeriesProvider(appPaths, httpClient);
 }
示例#8
0
 public AniDbSeasonProvider(IApplicationPaths appPaths)
 {
     _seriesProvider = new AniDbSeriesProvider(appPaths);
 }
示例#9
0
 public AniDbMovieProvider(IApplicationPaths appPaths, IHttpClient httpClient, ILoggerFactory loggerFactory)
 {
     _seriesProvider = new AniDbSeriesProvider(appPaths, httpClient);
     _log            = loggerFactory.CreateLogger("AniDB");
 }