示例#1
0
 public AudioDbArtistProvider(IServerConfigurationManager config, IFileSystem fileSystem, IHttpClient httpClient, IJsonSerializer json)
 {
     _config     = config;
     _fileSystem = fileSystem;
     _httpClient = httpClient;
     _json       = json;
     Current     = this;
 }
        public async Task <IEnumerable <RemoteImageInfo> > GetImages(IHasImages item, CancellationToken cancellationToken)
        {
            var id = item.GetProviderId(MetadataProviders.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>());
        }