From 57d7e9fccc1434d51876ab9baf23c20c80140706 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 12 May 2013 10:06:08 -0400 Subject: [PATCH] fixes #268 - (Multicd) Albums with discnumbers in subfolders on filesystem = Multiple album objects --- MediaBrowser.Api/BaseApiService.cs | 7 +++- .../Entities/Audio/MusicAlbumDisc.cs | 25 ++++++++++++++ .../MediaBrowser.Controller.csproj | 1 + .../Resolvers/Audio/MusicAlbumDiscResolver.cs | 33 +++++++++++++++++++ .../Resolvers/Audio/MusicAlbumResolver.cs | 10 +++--- ...MediaBrowser.Server.Implementations.csproj | 1 + 6 files changed, 71 insertions(+), 6 deletions(-) create mode 100644 MediaBrowser.Controller/Entities/Audio/MusicAlbumDisc.cs create mode 100644 MediaBrowser.Server.Implementations/Library/Resolvers/Audio/MusicAlbumDiscResolver.cs diff --git a/MediaBrowser.Api/BaseApiService.cs b/MediaBrowser.Api/BaseApiService.cs index ee90d2134..23d9b0126 100644 --- a/MediaBrowser.Api/BaseApiService.cs +++ b/MediaBrowser.Api/BaseApiService.cs @@ -128,7 +128,12 @@ namespace MediaBrowser.Api if (auth.ContainsKey("UserId")) { - user = UserManager.GetUserById(new Guid(auth["UserId"])); + var userId = auth["UserId"]; + + if (!string.IsNullOrEmpty(userId)) + { + user = UserManager.GetUserById(new Guid(userId)); + } } var deviceId = auth["DeviceId"]; diff --git a/MediaBrowser.Controller/Entities/Audio/MusicAlbumDisc.cs b/MediaBrowser.Controller/Entities/Audio/MusicAlbumDisc.cs new file mode 100644 index 000000000..9007a1bfd --- /dev/null +++ b/MediaBrowser.Controller/Entities/Audio/MusicAlbumDisc.cs @@ -0,0 +1,25 @@ + +namespace MediaBrowser.Controller.Entities.Audio +{ + /// + /// Class MusicAlbumDisc + /// + public class MusicAlbumDisc : Folder + { + /// + /// Gets or sets the display type of the media. + /// + /// The display type of the media. + public override string DisplayMediaType + { + get + { + return "Disc"; + } + set + { + base.DisplayMediaType = value; + } + } + } +} diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj index 2ffa8333a..3e8eed152 100644 --- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj +++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj @@ -71,6 +71,7 @@ + diff --git a/MediaBrowser.Server.Implementations/Library/Resolvers/Audio/MusicAlbumDiscResolver.cs b/MediaBrowser.Server.Implementations/Library/Resolvers/Audio/MusicAlbumDiscResolver.cs new file mode 100644 index 000000000..9a1065db5 --- /dev/null +++ b/MediaBrowser.Server.Implementations/Library/Resolvers/Audio/MusicAlbumDiscResolver.cs @@ -0,0 +1,33 @@ +using MediaBrowser.Controller.Entities.Audio; +using MediaBrowser.Controller.Library; +using MediaBrowser.Controller.Resolvers; + +namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio +{ + /// + /// Class MusicAlbumDiscResolver + /// + public class MusicAlbumDiscResolver : ItemResolver + { + /// + /// Gets the priority. + /// + /// The priority. + public override ResolverPriority Priority + { + get { return ResolverPriority.Third; } // we need to be ahead of the generic folder resolver but behind the movie one + } + + /// + /// Resolves the specified args. + /// + /// The args. + /// MusicAlbum. + protected override MusicAlbumDisc Resolve(ItemResolveArgs args) + { + if (!args.IsDirectory) return null; + + return args.Parent is MusicAlbum ? new MusicAlbumDisc() : null; + } + } +} diff --git a/MediaBrowser.Server.Implementations/Library/Resolvers/Audio/MusicAlbumResolver.cs b/MediaBrowser.Server.Implementations/Library/Resolvers/Audio/MusicAlbumResolver.cs index 411e431aa..98e99baa2 100644 --- a/MediaBrowser.Server.Implementations/Library/Resolvers/Audio/MusicAlbumResolver.cs +++ b/MediaBrowser.Server.Implementations/Library/Resolvers/Audio/MusicAlbumResolver.cs @@ -1,10 +1,9 @@ -using System.Collections.Generic; -using System.IO; -using System.Linq; -using MediaBrowser.Controller.Entities.Audio; -using MediaBrowser.Controller.IO; +using MediaBrowser.Controller.Entities.Audio; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Resolvers; +using System.Collections.Generic; +using System.IO; +using System.Linq; namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio { @@ -34,6 +33,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio //Avoid mis-identifying top folders if (args.Parent == null) return null; if (args.Parent.IsRoot) return null; + if (args.Parent is MusicAlbum) return null; return IsMusicAlbum(args) ? new MusicAlbum() : null; } diff --git a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj index 55a6ff9c8..22d4195a2 100644 --- a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj +++ b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj @@ -129,6 +129,7 @@ +