diff --git a/MediaBrowser.Controller/Entities/Audio/Artist.cs b/MediaBrowser.Controller/Entities/Audio/Artist.cs index 07bb68b95..15bdefb02 100644 --- a/MediaBrowser.Controller/Entities/Audio/Artist.cs +++ b/MediaBrowser.Controller/Entities/Audio/Artist.cs @@ -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 /// System.String. 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; }); } + + /// + /// Gets the user data key. + /// + /// The item. + /// System.String. + public static string GetUserDataKey(BaseItem item) + { + var id = item.GetProviderId(MetadataProviders.Musicbrainz); + + if (!string.IsNullOrEmpty(id)) + { + return id; + } + + return "Artist-" + item.Name; + } } } diff --git a/MediaBrowser.Controller/Entities/Audio/Audio.cs b/MediaBrowser.Controller/Entities/Audio/Audio.cs index beb25f1f2..86a466402 100644 --- a/MediaBrowser.Controller/Entities/Audio/Audio.cs +++ b/MediaBrowser.Controller/Entities/Audio/Audio.cs @@ -40,7 +40,7 @@ namespace MediaBrowser.Controller.Entities.Audio /// /// The unknown album /// - private static readonly MusicAlbum UnknownAlbum = new MusicAlbum {Name = ""}; + private static readonly MusicAlbum UnknownAlbum = new MusicAlbum { Name = "" }; /// /// 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); } + + /// + /// Gets the user data key. + /// + /// System.String. + 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(); + } } } diff --git a/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs b/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs index 0c88eed5b..e4543222c 100644 --- a/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs +++ b/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs @@ -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 Artists { get; set; } + + /// + /// Gets the user data key. + /// + /// System.String. + 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 diff --git a/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs b/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs index e2bad64d4..75231ec6a 100644 --- a/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs +++ b/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs @@ -6,6 +6,19 @@ namespace MediaBrowser.Controller.Entities.Audio /// public class MusicArtist : Folder { + /// + /// Gets or sets the last fm image URL. + /// + /// The last fm image URL. public string LastFmImageUrl { get; set; } + + /// + /// Gets the user data key. + /// + /// System.String. + public override string GetUserDataKey() + { + return Artist.GetUserDataKey(this); + } } } diff --git a/MediaBrowser.Controller/Entities/Game.cs b/MediaBrowser.Controller/Entities/Game.cs index 6c15e7303..a71cfe34a 100644 --- a/MediaBrowser.Controller/Entities/Game.cs +++ b/MediaBrowser.Controller/Entities/Game.cs @@ -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(); + } } } diff --git a/MediaBrowser.Controller/Entities/GameSystem.cs b/MediaBrowser.Controller/Entities/GameSystem.cs index 644405b4d..c568dda12 100644 --- a/MediaBrowser.Controller/Entities/GameSystem.cs +++ b/MediaBrowser.Controller/Entities/GameSystem.cs @@ -25,5 +25,14 @@ namespace MediaBrowser.Controller.Entities /// /// The game system. public string GameSystemName { get; set; } + + /// + /// Gets the user data key. + /// + /// System.String. + public override string GetUserDataKey() + { + return GameSystemName ?? base.GetUserDataKey(); + } } }