public async Task <IEnumerable <RemoteSearchResult> > GetSearchResults(SeriesInfo searchInfo, CancellationToken cancellationToken) { var results = new Dictionary <string, RemoteSearchResult>(); var aid = searchInfo.ProviderIds.GetOrDefault(ProviderNames.AniSearch); if (!string.IsNullOrEmpty(aid)) { if (!results.ContainsKey(aid)) { results.Add(aid, await AniSearchApi.GetAnime(aid)); } } if (!string.IsNullOrEmpty(searchInfo.Name)) { List <string> ids = await AniSearchApi.Search_GetSeries_list(searchInfo.Name, cancellationToken); foreach (string a in ids) { results.Add(a, await AniSearchApi.GetAnime(a)); } } return(results.Values); }
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); }
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); }