public async Task <IEnumerable <RemoteImageInfo> > GetImages(BaseItem item, CancellationToken cancellationToken) #endif { IEnumerable <RemoteImageInfo> images = new List <RemoteImageInfo>(); if (item == null || !item.ProviderIds.TryGetValue(this.Name, out var curID)) { return(images); } try { images = await MetadataAPI.PeopleImages(curID, cancellationToken).ConfigureAwait(false); } catch (Exception e) { Logger.Error($"GetImages error: \"{e}\""); } if (images.Any()) { foreach (var image in images) { image.ProviderName = Plugin.Instance.Name; } } return(images); }
public async Task <IEnumerable <RemoteSearchResult> > GetSearchResults(PersonLookupInfo searchInfo, CancellationToken cancellationToken) { var result = new List <RemoteSearchResult>(); if (searchInfo == null) { return(result); } if (searchInfo.ProviderIds.TryGetValue(this.Name, out var curID) && !string.IsNullOrEmpty(curID)) { var actorData = new MetadataResult <Person>() { HasMetadata = false, Item = new Person(), }; IEnumerable <RemoteImageInfo> sceneImages = new List <RemoteImageInfo>(); try { actorData = await MetadataAPI.PeopleUpdate(curID, cancellationToken).ConfigureAwait(false); } catch (Exception e) { Logger.Error($"Update error: \"{e}\""); } try { sceneImages = await MetadataAPI.PeopleImages(curID, cancellationToken).ConfigureAwait(false); } catch (Exception e) { Logger.Error($"GetImages error: \"{e}\""); } if (actorData.HasMetadata) { result.Add(new RemoteSearchResult { ProviderIds = { { Plugin.Instance.Name, curID } }, Name = actorData.Item.ExternalId, ImageUrl = sceneImages?.Where(o => o.Type == ImageType.Primary).FirstOrDefault()?.Url, PremiereDate = actorData.Item.PremiereDate, }); } } if (searchInfo.ProviderIds.Any(o => !string.IsNullOrEmpty(o.Value))) { return(result); } try { result = await MetadataAPI.PeopleSearch(searchInfo.Name, cancellationToken).ConfigureAwait(false); } catch (Exception e) { Logger.Error($"Actor Search error: \"{e}\""); } return(result); }