key music user data using musicbrainz id's

This commit is contained in:
Luke Pulverenti 2013-10-01 19:33:50 -04:00
parent 59acec8143
commit 26ccfa9b0f
6 changed files with 103 additions and 9 deletions

View File

@ -1,11 +1,11 @@
using System.Globalization;
using System.Linq;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Entities;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Runtime.Serialization;
using MediaBrowser.Model.Entities;
namespace MediaBrowser.Controller.Entities.Audio
{
@ -27,7 +27,7 @@ namespace MediaBrowser.Controller.Entities.Audio
/// <returns>System.String.</returns>
public override string GetUserDataKey()
{
return "Artist-" + Name;
return GetUserDataKey(this);
}
[IgnoreDataMember]
@ -64,5 +64,22 @@ namespace MediaBrowser.Controller.Entities.Audio
return string.Compare(i.Name, artist.Name, CultureInfo.CurrentCulture, CompareOptions.IgnoreNonSpace | CompareOptions.IgnoreCase | CompareOptions.IgnoreSymbols) == 0;
});
}
/// <summary>
/// Gets the user data key.
/// </summary>
/// <param name="item">The item.</param>
/// <returns>System.String.</returns>
public static string GetUserDataKey(BaseItem item)
{
var id = item.GetProviderId(MetadataProviders.Musicbrainz);
if (!string.IsNullOrEmpty(id))
{
return id;
}
return "Artist-" + item.Name;
}
}
}

View File

@ -40,7 +40,7 @@ namespace MediaBrowser.Controller.Entities.Audio
/// <summary>
/// The unknown album
/// </summary>
private static readonly MusicAlbum UnknownAlbum = new MusicAlbum {Name = "<Unknown>"};
private static readonly MusicAlbum UnknownAlbum = new MusicAlbum { Name = "<Unknown>" };
/// <summary>
/// Override this to return the folder that should be used to construct a container
/// for this item in an index. GroupInIndex should be true as well.
@ -51,7 +51,7 @@ namespace MediaBrowser.Controller.Entities.Audio
{
get
{
return Parent is MusicAlbum ? Parent : Album != null ? new MusicAlbum {Name = Album, PrimaryImagePath = PrimaryImagePath } : UnknownAlbum;
return Parent is MusicAlbum ? Parent : Album != null ? new MusicAlbum { Name = Album, PrimaryImagePath = PrimaryImagePath } : UnknownAlbum;
}
}
@ -103,5 +103,30 @@ namespace MediaBrowser.Controller.Entities.Audio
{
return Artists.Contains(name, StringComparer.OrdinalIgnoreCase) || string.Equals(AlbumArtist, name, StringComparison.OrdinalIgnoreCase);
}
/// <summary>
/// Gets the user data key.
/// </summary>
/// <returns>System.String.</returns>
public override string GetUserDataKey()
{
var parent = Parent as MusicAlbum;
if (parent != null)
{
var id = parent.GetProviderId(MetadataProviders.MusicBrainzReleaseGroup) ??
parent.GetProviderId(MetadataProviders.Musicbrainz);
if (!string.IsNullOrEmpty(id) && IndexNumber.HasValue)
{
var songKey = (ParentIndexNumber != null ? ParentIndexNumber.Value.ToString("0000 - ") : "")
+ (IndexNumber.Value.ToString("0000 - "));
return id + songKey;
}
}
return base.GetUserDataKey();
}
}
}

View File

@ -1,4 +1,5 @@
using System;
using MediaBrowser.Model.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
@ -74,6 +75,29 @@ namespace MediaBrowser.Controller.Entities.Audio
public string AlbumArtist { get; set; }
public List<string> Artists { get; set; }
/// <summary>
/// Gets the user data key.
/// </summary>
/// <returns>System.String.</returns>
public override string GetUserDataKey()
{
var id = this.GetProviderId(MetadataProviders.MusicBrainzReleaseGroup);
if (!string.IsNullOrEmpty(id))
{
return id;
}
id = this.GetProviderId(MetadataProviders.Musicbrainz);
if (!string.IsNullOrEmpty(id))
{
return id;
}
return base.GetUserDataKey();
}
}
public class MusicAlbumDisc : Folder

View File

@ -6,6 +6,19 @@ namespace MediaBrowser.Controller.Entities.Audio
/// </summary>
public class MusicArtist : Folder
{
/// <summary>
/// Gets or sets the last fm image URL.
/// </summary>
/// <value>The last fm image URL.</value>
public string LastFmImageUrl { get; set; }
/// <summary>
/// Gets the user data key.
/// </summary>
/// <returns>System.String.</returns>
public override string GetUserDataKey()
{
return Artist.GetUserDataKey(this);
}
}
}

View File

@ -1,4 +1,5 @@
using System.Collections.Generic;
using MediaBrowser.Model.Entities;
using System.Collections.Generic;
namespace MediaBrowser.Controller.Entities
{
@ -68,5 +69,10 @@ namespace MediaBrowser.Controller.Entities
return !IsInMixedFolder;
}
}
public override string GetUserDataKey()
{
return this.GetProviderId(MetadataProviders.Gamesdb) ?? base.GetUserDataKey();
}
}
}

View File

@ -25,5 +25,14 @@ namespace MediaBrowser.Controller.Entities
/// </summary>
/// <value>The game system.</value>
public string GameSystemName { get; set; }
/// <summary>
/// Gets the user data key.
/// </summary>
/// <returns>System.String.</returns>
public override string GetUserDataKey()
{
return GameSystemName ?? base.GetUserDataKey();
}
}
}