using MediaBrowser.Common.Net; using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities.Audio; using MediaBrowser.Controller.Library; using MediaBrowser.Model.Logging; using MediaBrowser.Model.Serialization; using System.Threading; using System.Threading.Tasks; namespace MediaBrowser.Providers.Music { /// /// Class LastfmArtistByNameProvider /// public class LastfmArtistByNameProvider : LastfmArtistProvider { /// /// Initializes a new instance of the class. /// /// The json serializer. /// The HTTP client. /// The log manager. /// The configuration manager. /// The library manager. public LastfmArtistByNameProvider(IJsonSerializer jsonSerializer, IHttpClient httpClient, ILogManager logManager, IServerConfigurationManager configurationManager, ILibraryManager libraryManager) : base(jsonSerializer, httpClient, logManager, configurationManager, libraryManager) { } /// /// Gets a value indicating whether [save local meta]. /// /// true if [save local meta]; otherwise, false. protected override bool SaveLocalMeta { get { return true; } } /// /// Supportses the specified item. /// /// The item. /// true if XXXX, false otherwise public override bool Supports(BaseItem item) { return item is Artist; } /// /// Gets the provider version. /// /// The provider version. protected override string ProviderVersion { get { return "7"; } } /// /// Fetches the lastfm data. /// /// The item. /// The music brainz id. /// The cancellation token. /// Task. protected override async Task FetchLastfmData(BaseItem item, string musicBrainzId, bool force, CancellationToken cancellationToken) { var artist = (Artist)item; // See if we can avoid an http request by finding the matching MusicArtist entity var musicArtist = Artist.FindMusicArtist(artist, LibraryManager); if (musicArtist != null && !force) { LastfmHelper.ProcessArtistData(musicArtist, artist); } else { await base.FetchLastfmData(item, musicBrainzId, force, cancellationToken).ConfigureAwait(false); } } } }