Exemple #1
0
 public AudioDbArtistProvider(IServerConfigurationManager config, IFileSystem fileSystem, IHttpClientFactory httpClientFactory, IJsonSerializer json)
 {
     _config            = config;
     _fileSystem        = fileSystem;
     _httpClientFactory = httpClientFactory;
     _json   = json;
     Current = this;
 }
Exemple #2
0
        /// <inheritdoc />
        public async Task <IEnumerable <RemoteImageInfo> > GetImages(BaseItem item, CancellationToken cancellationToken)
        {
            var id = item.GetProviderId(MetadataProvider.MusicBrainzArtist);

            if (!string.IsNullOrWhiteSpace(id))
            {
                await AudioDbArtistProvider.Current.EnsureArtistInfo(id, cancellationToken).ConfigureAwait(false);

                var path = AudioDbArtistProvider.GetArtistInfoPath(_config.ApplicationPaths, id);

                var obj = _json.DeserializeFromFile <AudioDbArtistProvider.RootObject>(path);

                if (obj != null && obj.artists != null && obj.artists.Count > 0)
                {
                    return(GetImages(obj.artists[0]));
                }
            }

            return(new List <RemoteImageInfo>());
        }