cache MusicBrainzReleaseGroupId

This commit is contained in:
Luke Pulverenti 2013-05-02 21:35:50 -04:00
parent 19a95edf58
commit b79840e20f
2 changed files with 23 additions and 3 deletions

View File

@ -150,6 +150,10 @@ namespace MediaBrowser.Controller.Entities.Audio
return RecursiveChildren.OfType<Audio>().Any(i => i.HasArtist(artist)); return RecursiveChildren.OfType<Audio>().Any(i => i.HasArtist(artist));
} }
/// <summary>
/// Gets or sets the name.
/// </summary>
/// <value>The name.</value>
public override string Name public override string Name
{ {
get get
@ -164,6 +168,10 @@ namespace MediaBrowser.Controller.Entities.Audio
} }
} }
/// <summary>
/// Gets or sets the display type of the media.
/// </summary>
/// <value>The display type of the media.</value>
public override string DisplayMediaType public override string DisplayMediaType
{ {
get get
@ -175,5 +183,11 @@ namespace MediaBrowser.Controller.Entities.Audio
base.DisplayMediaType = value; base.DisplayMediaType = value;
} }
} }
/// <summary>
/// Gets or sets the music brainz release group id.
/// </summary>
/// <value>The music brainz release group id.</value>
public string MusicBrainzReleaseGroupId { get; set; }
} }
} }

View File

@ -116,16 +116,22 @@ namespace MediaBrowser.Controller.Providers.Music
{ {
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();
var releaseGroupId = await GetReleaseGroupId(item.GetProviderId(MetadataProviders.Musicbrainz), cancellationToken).ConfigureAwait(false); var album = (MusicAlbum)item;
if (string.IsNullOrEmpty(releaseGroupId)) if (string.IsNullOrEmpty(album.MusicBrainzReleaseGroupId))
{
album.MusicBrainzReleaseGroupId = await GetReleaseGroupId(item.GetProviderId(MetadataProviders.Musicbrainz), cancellationToken).ConfigureAwait(false);
}
// If still empty there's nothing more we can do
if (string.IsNullOrEmpty(album.MusicBrainzReleaseGroupId))
{ {
SetLastRefreshed(item, DateTime.UtcNow); SetLastRefreshed(item, DateTime.UtcNow);
return true; return true;
} }
var url = string.Format("http://api.fanart.tv/webservice/album/{0}/{1}/xml/all/1/1", APIKey, releaseGroupId); var url = string.Format("http://api.fanart.tv/webservice/album/{0}/{1}/xml/all/1/1", APIKey, album.MusicBrainzReleaseGroupId);
var doc = new XmlDocument(); var doc = new XmlDocument();