public async Task <MetadataResult <Movie> > GetMetadata(MovieInfo info, CancellationToken cancellationToken) { var result = new MetadataResult <Movie>(); Media media = null; var aid = info.ProviderIds.GetOrDefault(ProviderNames.AniList); if (!string.IsNullOrEmpty(aid)) { media = await _aniListApi.GetAnime(aid); } else { _log.LogInformation("Start AniList... Searching({Name})", info.Name); MediaSearchResult msr = await _aniListApi.Search_GetSeries(info.Name, cancellationToken); if (msr != null) { media = await _aniListApi.GetAnime(msr.id.ToString()); } } if (media != null) { result.HasMetadata = true; result.Item = media.ToMovie(); result.People = media.GetPeopleInfo(); result.Provider = ProviderNames.AniList; StoreImageUrl(media.id.ToString(), media.GetImageUrl(), "image"); } return(result); }
public async Task <IEnumerable <RemoteSearchResult> > GetSearchResults(SeriesInfo searchInfo, CancellationToken cancellationToken) { var results = new Dictionary <string, RemoteSearchResult>(); var aid = searchInfo.ProviderIds.GetOrDefault(ProviderNames.AniList); if (!string.IsNullOrEmpty(aid)) { if (!results.ContainsKey(aid)) { results.Add(aid, await _aniListApi.GetAnime(aid).ConfigureAwait(false)); } } if (!string.IsNullOrEmpty(searchInfo.Name)) { List <string> ids = await _aniListApi.Search_GetSeries_list(searchInfo.Name, cancellationToken).ConfigureAwait(false); foreach (string a in ids) { results.Add(a, await _aniListApi.GetAnime(a).ConfigureAwait(false)); } } return(results.Values); }
public async Task <IEnumerable <RemoteImageInfo> > GetImages(string aid, CancellationToken cancellationToken) { var list = new List <RemoteImageInfo>(); if (!string.IsNullOrEmpty(aid)) { Media media = await _aniListApi.GetAnime(aid); if (media != null) { if (media.GetImageUrl() != null) { list.Add(new RemoteImageInfo { ProviderName = Name, Type = ImageType.Primary, Url = media.GetImageUrl() }); } if (media.bannerImage != null) { list.Add(new RemoteImageInfo { ProviderName = Name, Type = ImageType.Banner, Url = media.bannerImage }); } } } return(list); }