예제 #1
0
        public async Task <IEnumerable <RemoteSearchResult> > GetSearchResults(SeriesInfo searchInfo, CancellationToken cancellationToken)
        {
            var metadata = await GetMetadata(searchInfo, cancellationToken).ConfigureAwait(false);

            var list = new List <RemoteSearchResult>();

            if (metadata.HasMetadata)
            {
                var seriesId      = metadata.Item.ProviderIds.GetOrDefault(ProviderNames.AniDb);
                var imageProvider = new AniDbImageProvider(_appPaths);
                var images        = await imageProvider.GetImages(seriesId, cancellationToken);

                var res = new RemoteSearchResult
                {
                    Name               = metadata.Item.Name,
                    PremiereDate       = metadata.Item.PremiereDate,
                    ProductionYear     = metadata.Item.ProductionYear,
                    ImageUrl           = images.Any() ? images.First().Url : null,
                    ProviderIds        = metadata.Item.ProviderIds,
                    SearchProviderName = Name
                };

                list.Add(res);
            }

            return(list);
        }
예제 #2
0
        public async Task <IEnumerable <RemoteSearchResult> > GetSearchResults(SeriesInfo searchInfo, CancellationToken cancellationToken)
        {
            var results = new List <RemoteSearchResult>();
            var animeId = searchInfo.ProviderIds.GetOrDefault(ProviderNames.AniDb);

            if (!string.IsNullOrEmpty(animeId))
            {
                var resultMetadata = await GetMetadataForId(animeId, searchInfo, cancellationToken);

                if (resultMetadata.HasMetadata)
                {
                    var imageProvider = new AniDbImageProvider(_appPaths);
                    var images        = await imageProvider.GetImages(animeId, cancellationToken);

                    results.Add(MetadataToRemoteSearchResult(resultMetadata, images));
                }
            }

            if (!string.IsNullOrEmpty(searchInfo.Name))
            {
                List <RemoteSearchResult> name_results = await GetSearchResultsByName(searchInfo.Name, searchInfo, cancellationToken).ConfigureAwait(false);

                foreach (var media in name_results)
                {
                    results.Add(media);
                }
            }

            return(results);
        }
예제 #3
0
        public async Task <List <RemoteSearchResult> > GetSearchResultsByName(string name, SeriesInfo searchInfo, CancellationToken cancellationToken)
        {
            var imageProvider = new AniDbImageProvider(_appPaths);
            var results       = new List <RemoteSearchResult>();

            List <string> ids = await Equals_check.XmlSearch(name, cancellationToken);

            foreach (string id in ids)
            {
                var resultMetadata = await GetMetadataForId(id, searchInfo, cancellationToken);

                if (resultMetadata.HasMetadata)
                {
                    var images = await imageProvider.GetImages(id, cancellationToken);

                    results.Add(MetadataToRemoteSearchResult(resultMetadata, images));
                }
            }
            return(results);
        }
        public Task <HttpResponseMessage> GetImageResponse(string url, CancellationToken cancellationToken)
        {
            var imageProvider = new AniDbImageProvider(_configurationManager.ApplicationPaths);

            return(imageProvider.GetImageResponse(url, cancellationToken));
        }