Пример #1
0
        public async Task <IEnumerable <RemoteImageInfo> > GetImages(string aid, CancellationToken cancellationToken)
        {
            var list = new List <RemoteImageInfo>();

            if (!string.IsNullOrEmpty(aid))
            {
                var primary = await AniSearchApi.Get_ImageUrl(await AniSearchApi.WebRequestAPI(AniSearchApi.AniSearch_anime_link + aid));

                list.Add(new RemoteImageInfo
                {
                    ProviderName = Name,
                    Type         = ImageType.Primary,
                    Url          = primary
                });
            }
            return(list);
        }
Пример #2
0
        public async Task <MetadataResult <Series> > GetMetadata(SeriesInfo info, CancellationToken cancellationToken)
        {
            var result = new MetadataResult <Series>();

            var aid = info.ProviderIds.GetOrDefault(ProviderNames.AniSearch);

            if (string.IsNullOrEmpty(aid))
            {
                _log.LogInformation("Start AniSearch... Searching({Name})", info.Name);
                aid = await AniSearchApi.FindSeries(info.Name, cancellationToken);
            }

            if (!string.IsNullOrEmpty(aid))
            {
                string WebContent = await AniSearchApi.WebRequestAPI(AniSearchApi.AniSearch_anime_link + aid);

                result.Item        = new Series();
                result.HasMetadata = true;

                result.Item.ProviderIds.Add(ProviderNames.AniSearch, aid);
                result.Item.Overview = await AniSearchApi.Get_Overview(WebContent);

                try
                {
                    //AniSearch has a max rating of 5
                    result.Item.CommunityRating = (float.Parse(await AniSearchApi.Get_Rating(WebContent), System.Globalization.CultureInfo.InvariantCulture) * 2);
                }
                catch (Exception) { }
                foreach (var genre in await AniSearchApi.Get_Genre(WebContent))
                {
                    result.Item.AddGenre(genre);
                }
                GenreHelper.CleanupGenres(result.Item);
                StoreImageUrl(aid, await AniSearchApi.Get_ImageUrl(WebContent), "image");
            }
            return(result);
        }