key music user data using musicbrainz id's

pull/702/head
Luke Pulverenti 11 years ago
parent 59acec8143
commit 26ccfa9b0f

@ -1,11 +1,11 @@
using System.Globalization; using MediaBrowser.Controller.Library;
using System.Linq;
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Dto; using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Entities;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Runtime.Serialization; using System.Runtime.Serialization;
using MediaBrowser.Model.Entities;
namespace MediaBrowser.Controller.Entities.Audio namespace MediaBrowser.Controller.Entities.Audio
{ {
@ -27,7 +27,7 @@ namespace MediaBrowser.Controller.Entities.Audio
/// <returns>System.String.</returns> /// <returns>System.String.</returns>
public override string GetUserDataKey() public override string GetUserDataKey()
{ {
return "Artist-" + Name; return GetUserDataKey(this);
} }
[IgnoreDataMember] [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; 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;
}
} }
} }

@ -40,7 +40,7 @@ namespace MediaBrowser.Controller.Entities.Audio
/// <summary> /// <summary>
/// The unknown album /// The unknown album
/// </summary> /// </summary>
private static readonly MusicAlbum UnknownAlbum = new MusicAlbum {Name = "<Unknown>"}; private static readonly MusicAlbum UnknownAlbum = new MusicAlbum { Name = "<Unknown>" };
/// <summary> /// <summary>
/// Override this to return the folder that should be used to construct a container /// 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. /// for this item in an index. GroupInIndex should be true as well.
@ -51,7 +51,7 @@ namespace MediaBrowser.Controller.Entities.Audio
{ {
get 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); 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();
}
} }
} }

@ -1,4 +1,5 @@
using System; using MediaBrowser.Model.Entities;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Runtime.Serialization; using System.Runtime.Serialization;
@ -74,6 +75,29 @@ namespace MediaBrowser.Controller.Entities.Audio
public string AlbumArtist { get; set; } public string AlbumArtist { get; set; }
public List<string> Artists { 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 public class MusicAlbumDisc : Folder

@ -6,6 +6,19 @@ namespace MediaBrowser.Controller.Entities.Audio
/// </summary> /// </summary>
public class MusicArtist : Folder 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; } public string LastFmImageUrl { get; set; }
/// <summary>
/// Gets the user data key.
/// </summary>
/// <returns>System.String.</returns>
public override string GetUserDataKey()
{
return Artist.GetUserDataKey(this);
}
} }
} }

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

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

Loading…
Cancel
Save