public static async Task <List <RemoteSearchResult> > GetSearchResultsFromUpdate(IProviderBase provider, int[] siteNum, string[] sceneID, CancellationToken cancellationToken) { var result = new List <RemoteSearchResult>(); var curID = new List <string>() { siteNum[0].ToString(CultureInfo.InvariantCulture), siteNum[1].ToString(CultureInfo.InvariantCulture), }; curID.AddRange(sceneID); var sceneData = await provider.Update(siteNum, sceneID, cancellationToken).ConfigureAwait(false); if (!string.IsNullOrEmpty(sceneData.Item.Name)) { sceneData.Item.ProviderIds.Add(Plugin.Instance.Name, string.Join("#", curID)); var posters = (await provider.GetImages(siteNum, sceneID, sceneData.Item, cancellationToken).ConfigureAwait(false)).Where(o => o.Type == ImageType.Primary); var res = new RemoteSearchResult { ProviderIds = sceneData.Item.ProviderIds, Name = sceneData.Item.Name, PremiereDate = sceneData.Item.PremiereDate, }; if (!string.IsNullOrEmpty(sceneData.Item.OriginalTitle)) { res.Name = $"{sceneData.Item.OriginalTitle} {sceneData.Item.Name}"; } if (posters.Any()) { res.ImageUrl = posters.First().Url; } result.Add(res); } return(result); }
public static async Task <List <RemoteSearchResult> > GetSearchResultsFromUpdate(IProviderBase provider, int[] siteNum, string[] sceneID, DateTime?searchDate, CancellationToken cancellationToken) { var result = new List <RemoteSearchResult>(); var sceneData = await provider.Update(siteNum, sceneID, cancellationToken).ConfigureAwait(false); if (!string.IsNullOrEmpty(sceneData.Item.Name)) { sceneData.Item.ProviderIds[Plugin.Instance.Name] = string.Join("#", sceneID); var posters = (await provider.GetImages(siteNum, sceneID, sceneData.Item, cancellationToken).ConfigureAwait(false)).Where(o => o.Type == ImageType.Primary); var res = new RemoteSearchResult { ProviderIds = sceneData.Item.ProviderIds, Name = sceneData.Item.Name, PremiereDate = sceneData.Item.PremiereDate, }; if (searchDate.HasValue && !res.PremiereDate.HasValue) { res.PremiereDate = searchDate.Value; } if (!string.IsNullOrEmpty(sceneData.Item.OriginalTitle)) { res.Name = $"{sceneData.Item.OriginalTitle} {sceneData.Item.Name}"; } if (posters.Any()) { res.ImageUrl = posters.First().Url; } result.Add(res); } return(result); }