2013-04-22 04:38:03 +00:00
|
|
|
|
using MediaBrowser.Common.Net;
|
|
|
|
|
using MediaBrowser.Controller.Configuration;
|
|
|
|
|
using MediaBrowser.Controller.Entities;
|
|
|
|
|
using MediaBrowser.Controller.Entities.Audio;
|
2013-05-06 19:31:57 +00:00
|
|
|
|
using MediaBrowser.Controller.Library;
|
2013-04-22 04:38:03 +00:00
|
|
|
|
using MediaBrowser.Model.Logging;
|
|
|
|
|
using MediaBrowser.Model.Serialization;
|
2013-05-27 15:02:16 +00:00
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
2013-04-22 04:38:03 +00:00
|
|
|
|
|
2013-06-09 16:47:28 +00:00
|
|
|
|
namespace MediaBrowser.Providers.Music
|
2013-04-22 04:38:03 +00:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Class LastfmArtistByNameProvider
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class LastfmArtistByNameProvider : LastfmArtistProvider
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
2013-05-27 15:02:16 +00:00
|
|
|
|
/// Initializes a new instance of the <see cref="LastfmArtistByNameProvider" /> class.
|
2013-04-22 04:38:03 +00:00
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="jsonSerializer">The json serializer.</param>
|
|
|
|
|
/// <param name="httpClient">The HTTP client.</param>
|
|
|
|
|
/// <param name="logManager">The log manager.</param>
|
|
|
|
|
/// <param name="configurationManager">The configuration manager.</param>
|
2013-05-27 15:02:16 +00:00
|
|
|
|
/// <param name="libraryManager">The library manager.</param>
|
2013-06-23 18:55:30 +00:00
|
|
|
|
public LastfmArtistByNameProvider(IJsonSerializer jsonSerializer, IHttpClient httpClient, ILogManager logManager, IServerConfigurationManager configurationManager, ILibraryManager libraryManager)
|
|
|
|
|
: base(jsonSerializer, httpClient, logManager, configurationManager, libraryManager)
|
2013-04-22 04:38:03 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets a value indicating whether [save local meta].
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value><c>true</c> if [save local meta]; otherwise, <c>false</c>.</value>
|
|
|
|
|
protected override bool SaveLocalMeta
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Supportses the specified item.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="item">The item.</param>
|
|
|
|
|
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
|
|
|
|
|
public override bool Supports(BaseItem item)
|
|
|
|
|
{
|
|
|
|
|
return item is Artist;
|
|
|
|
|
}
|
2013-05-27 15:02:16 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the provider version.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The provider version.</value>
|
|
|
|
|
protected override string ProviderVersion
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return "7";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Fetches the lastfm data.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="item">The item.</param>
|
|
|
|
|
/// <param name="musicBrainzId">The music brainz id.</param>
|
|
|
|
|
/// <param name="cancellationToken">The cancellation token.</param>
|
|
|
|
|
/// <returns>Task.</returns>
|
2013-09-06 15:23:20 +00:00
|
|
|
|
protected override async Task FetchLastfmData(BaseItem item, string musicBrainzId, bool force, CancellationToken cancellationToken)
|
2013-05-27 15:02:16 +00:00
|
|
|
|
{
|
|
|
|
|
var artist = (Artist)item;
|
|
|
|
|
|
|
|
|
|
// See if we can avoid an http request by finding the matching MusicArtist entity
|
2013-10-01 18:31:32 +00:00
|
|
|
|
var musicArtist = Artist.FindMusicArtist(artist, LibraryManager);
|
2013-05-27 15:02:16 +00:00
|
|
|
|
|
2013-09-06 15:23:20 +00:00
|
|
|
|
if (musicArtist != null && !force)
|
2013-05-27 15:02:16 +00:00
|
|
|
|
{
|
|
|
|
|
LastfmHelper.ProcessArtistData(musicArtist, artist);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2013-09-06 15:23:20 +00:00
|
|
|
|
await base.FetchLastfmData(item, musicBrainzId, force, cancellationToken).ConfigureAwait(false);
|
2013-05-27 15:02:16 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2013-04-22 04:38:03 +00:00
|
|
|
|
}
|
|
|
|
|
}
|