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 <RemoteSearchResult> > GetSearchResults(MovieInfo searchInfo, CancellationToken cancellationToken) { var results = new List <RemoteSearchResult>(); var aid = searchInfo.ProviderIds.GetOrDefault(ProviderNames.AniList); if (!string.IsNullOrEmpty(aid)) { Media aid_result = await _aniListApi.GetAnime(aid).ConfigureAwait(false); if (aid_result != null) { results.Add(aid_result.ToSearchResult()); } } if (!string.IsNullOrEmpty(searchInfo.Name)) { List <MediaSearchResult> name_results = await _aniListApi.Search_GetSeries_list(searchInfo.Name, cancellationToken).ConfigureAwait(false); foreach (var media in name_results) { results.Add(media.ToSearchResult()); } } return(results); }