From 8726b9ca952b33e8a4810f27ac6a00807df676be Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 13 Jun 2013 14:17:42 -0400 Subject: [PATCH] Set initial display media type at resolve time --- .../Entities/Audio/Audio.cs | 12 ------ .../Entities/Audio/MusicAlbum.cs | 16 ------- .../Entities/Audio/MusicAlbumDisc.cs | 16 +------ MediaBrowser.Controller/Entities/BaseItem.cs | 12 +++--- .../Entities/BasePluginFolder.cs | 42 +------------------ MediaBrowser.Controller/Entities/User.cs | 16 ------- .../Library/LibraryManager.cs | 14 ++++++- .../Library/Resolvers/Audio/AudioResolver.cs | 5 ++- .../Resolvers/Audio/MusicAlbumDiscResolver.cs | 6 ++- .../Resolvers/Audio/MusicAlbumResolver.cs | 6 ++- 10 files changed, 35 insertions(+), 110 deletions(-) diff --git a/MediaBrowser.Controller/Entities/Audio/Audio.cs b/MediaBrowser.Controller/Entities/Audio/Audio.cs index dd28218ce..5ee1e8152 100644 --- a/MediaBrowser.Controller/Entities/Audio/Audio.cs +++ b/MediaBrowser.Controller/Entities/Audio/Audio.cs @@ -101,17 +101,5 @@ namespace MediaBrowser.Controller.Entities.Audio { return string.Equals(Artist, name, StringComparison.OrdinalIgnoreCase) || string.Equals(AlbumArtist, name, StringComparison.OrdinalIgnoreCase); } - - public override string DisplayMediaType - { - get - { - return "Song"; - } - set - { - base.DisplayMediaType = value; - } - } } } diff --git a/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs b/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs index f3fdbb499..79624826a 100644 --- a/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs +++ b/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs @@ -164,22 +164,6 @@ namespace MediaBrowser.Controller.Entities.Audio } } - /// - /// Gets or sets the display type of the media. - /// - /// The display type of the media. - public override string DisplayMediaType - { - get - { - return "Album"; - } - set - { - base.DisplayMediaType = value; - } - } - /// /// Gets or sets the music brainz release group id. /// diff --git a/MediaBrowser.Controller/Entities/Audio/MusicAlbumDisc.cs b/MediaBrowser.Controller/Entities/Audio/MusicAlbumDisc.cs index 9007a1bfd..27b7337c8 100644 --- a/MediaBrowser.Controller/Entities/Audio/MusicAlbumDisc.cs +++ b/MediaBrowser.Controller/Entities/Audio/MusicAlbumDisc.cs @@ -6,20 +6,6 @@ namespace MediaBrowser.Controller.Entities.Audio /// 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/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index 9e28e4242..fbed70af9 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -48,7 +48,7 @@ namespace MediaBrowser.Controller.Entities /// The supported image extensions /// public static readonly string[] SupportedImageExtensions = new[] { ".png", ".jpg", ".jpeg" }; - + /// /// The trailer folder name /// @@ -82,7 +82,7 @@ namespace MediaBrowser.Controller.Entities /// Gets or sets the id. /// /// The id. - public virtual Guid Id { get; set; } + public Guid Id { get; set; } /// /// Gets or sets the path. @@ -171,7 +171,7 @@ namespace MediaBrowser.Controller.Entities /// /// The locked images. public List LockedImages { get; set; } - + /// /// Determines whether the item has a saved local image of the specified name (jpg or png). /// @@ -764,7 +764,7 @@ namespace MediaBrowser.Controller.Entities return false; })); - var trailers= LibraryManager.ResolvePaths(files, null).Select(video => + var trailers = LibraryManager.ResolvePaths(files, null).Select(video => { // Try to retrieve it from the db. If we don't find it, use the resolved version var dbItem = LibraryManager.RetrieveItem(video.Id) as Trailer; @@ -964,7 +964,7 @@ namespace MediaBrowser.Controller.Entities return itemsChanged || results.Contains(true); } - + private async Task RefreshThemeVideos(CancellationToken cancellationToken, bool forceSave = false, bool forceRefresh = false, bool allowSlowProviders = true) { var newThemeVideos = LoadThemeVideos().ToList(); @@ -980,7 +980,7 @@ namespace MediaBrowser.Controller.Entities return themeVideosChanged || results.Contains(true); } - + /// /// Refreshes the theme songs. /// diff --git a/MediaBrowser.Controller/Entities/BasePluginFolder.cs b/MediaBrowser.Controller/Entities/BasePluginFolder.cs index bf8040a9f..fabb69c0f 100644 --- a/MediaBrowser.Controller/Entities/BasePluginFolder.cs +++ b/MediaBrowser.Controller/Entities/BasePluginFolder.cs @@ -1,6 +1,4 @@ -using MediaBrowser.Common.Extensions; -using System; -using MediaBrowser.Model.Entities; +using MediaBrowser.Model.Entities; namespace MediaBrowser.Controller.Entities { @@ -10,27 +8,6 @@ namespace MediaBrowser.Controller.Entities /// public abstract class BasePluginFolder : Folder, ICollectionFolder, IByReferenceItem { - /// - /// Gets or sets the id. - /// - /// The id. - public override Guid Id - { - get - { - // This doesn't get populated through the normal resolving process - if (base.Id == Guid.Empty) - { - base.Id = (Path ?? Name).GetMBId(GetType()); - } - return base.Id; - } - set - { - base.Id = value; - } - } - /// /// Gets or sets the type of the location. /// @@ -42,22 +19,5 @@ namespace MediaBrowser.Controller.Entities return LocationType.Virtual; } } - - - /// - /// We don't resolve normally so need to fill this in - /// - public override string DisplayMediaType - { - get - { - return "CollectionFolder"; // Plug-in folders are collection folders - } - set - { - base.DisplayMediaType = value; - } - } - } } diff --git a/MediaBrowser.Controller/Entities/User.cs b/MediaBrowser.Controller/Entities/User.cs index 65c3793e9..96507f269 100644 --- a/MediaBrowser.Controller/Entities/User.cs +++ b/MediaBrowser.Controller/Entities/User.cs @@ -74,22 +74,6 @@ namespace MediaBrowser.Controller.Entities } } - /// - /// Ensure this has a value - /// - /// The display type of the media. - public override string DisplayMediaType - { - get - { - return base.DisplayMediaType ?? GetType().Name; - } - set - { - base.DisplayMediaType = value; - } - } - /// /// The _root folder /// diff --git a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs index bc122ff6d..faf6d287c 100644 --- a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs +++ b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs @@ -569,7 +569,19 @@ namespace MediaBrowser.Server.Implementations.Library // Add in the plug-in folders foreach (var child in PluginFolderCreators) { - rootFolder.AddVirtualChild(child.GetFolder()); + var folder = child.GetFolder(); + + if (string.IsNullOrEmpty(folder.DisplayMediaType)) + { + folder.DisplayMediaType = "CollectionFolder"; + } + + if (folder.Id == Guid.Empty) + { + folder.Id = (folder.Path ?? folder.Name ?? folder.GetType().Name).GetMBId(folder.GetType()); + } + + rootFolder.AddVirtualChild(folder); } return rootFolder; diff --git a/MediaBrowser.Server.Implementations/Library/Resolvers/Audio/AudioResolver.cs b/MediaBrowser.Server.Implementations/Library/Resolvers/Audio/AudioResolver.cs index 3c6cc654f..485784397 100644 --- a/MediaBrowser.Server.Implementations/Library/Resolvers/Audio/AudioResolver.cs +++ b/MediaBrowser.Server.Implementations/Library/Resolvers/Audio/AudioResolver.cs @@ -30,7 +30,10 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio { if (EntityResolutionHelper.IsAudioFile(args.Path)) { - return new Controller.Entities.Audio.Audio(); + return new Controller.Entities.Audio.Audio + { + DisplayMediaType = "Song" + }; } } diff --git a/MediaBrowser.Server.Implementations/Library/Resolvers/Audio/MusicAlbumDiscResolver.cs b/MediaBrowser.Server.Implementations/Library/Resolvers/Audio/MusicAlbumDiscResolver.cs index 393002a6e..04b749ec0 100644 --- a/MediaBrowser.Server.Implementations/Library/Resolvers/Audio/MusicAlbumDiscResolver.cs +++ b/MediaBrowser.Server.Implementations/Library/Resolvers/Audio/MusicAlbumDiscResolver.cs @@ -27,7 +27,11 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio { if (!args.IsDirectory) return null; - return args.Parent is MusicAlbum ? new MusicAlbumDisc() : null; + return args.Parent is MusicAlbum ? new MusicAlbumDisc + { + DisplayMediaType = "Disc" + + } : null; } } } diff --git a/MediaBrowser.Server.Implementations/Library/Resolvers/Audio/MusicAlbumResolver.cs b/MediaBrowser.Server.Implementations/Library/Resolvers/Audio/MusicAlbumResolver.cs index 98e99baa2..4ee62b206 100644 --- a/MediaBrowser.Server.Implementations/Library/Resolvers/Audio/MusicAlbumResolver.cs +++ b/MediaBrowser.Server.Implementations/Library/Resolvers/Audio/MusicAlbumResolver.cs @@ -35,7 +35,11 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio if (args.Parent.IsRoot) return null; if (args.Parent is MusicAlbum) return null; - return IsMusicAlbum(args) ? new MusicAlbum() : null; + return IsMusicAlbum(args) ? new MusicAlbum + { + DisplayMediaType = "Album" + + } : null; }