Set initial display media type at resolve time

This commit is contained in:
Luke Pulverenti 2013-06-13 14:17:42 -04:00
parent 7d0a478183
commit 8726b9ca95
10 changed files with 35 additions and 110 deletions

View File

@ -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;
}
}
}
}

View File

@ -164,22 +164,6 @@ namespace MediaBrowser.Controller.Entities.Audio
}
}
/// <summary>
/// Gets or sets the display type of the media.
/// </summary>
/// <value>The display type of the media.</value>
public override string DisplayMediaType
{
get
{
return "Album";
}
set
{
base.DisplayMediaType = value;
}
}
/// <summary>
/// Gets or sets the music brainz release group id.
/// </summary>

View File

@ -6,20 +6,6 @@ namespace MediaBrowser.Controller.Entities.Audio
/// </summary>
public class MusicAlbumDisc : Folder
{
/// <summary>
/// Gets or sets the display type of the media.
/// </summary>
/// <value>The display type of the media.</value>
public override string DisplayMediaType
{
get
{
return "Disc";
}
set
{
base.DisplayMediaType = value;
}
}
}
}

View File

@ -48,7 +48,7 @@ namespace MediaBrowser.Controller.Entities
/// The supported image extensions
/// </summary>
public static readonly string[] SupportedImageExtensions = new[] { ".png", ".jpg", ".jpeg" };
/// <summary>
/// The trailer folder name
/// </summary>
@ -82,7 +82,7 @@ namespace MediaBrowser.Controller.Entities
/// Gets or sets the id.
/// </summary>
/// <value>The id.</value>
public virtual Guid Id { get; set; }
public Guid Id { get; set; }
/// <summary>
/// Gets or sets the path.
@ -171,7 +171,7 @@ namespace MediaBrowser.Controller.Entities
/// </summary>
/// <value>The locked images.</value>
public List<ImageType> LockedImages { get; set; }
/// <summary>
/// Determines whether the item has a saved local image of the specified name (jpg or png).
/// </summary>
@ -764,7 +764,7 @@ namespace MediaBrowser.Controller.Entities
return false;
}));
var trailers= LibraryManager.ResolvePaths<Trailer>(files, null).Select(video =>
var trailers = LibraryManager.ResolvePaths<Trailer>(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<bool> 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);
}
/// <summary>
/// Refreshes the theme songs.
/// </summary>

View File

@ -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
/// </summary>
public abstract class BasePluginFolder : Folder, ICollectionFolder, IByReferenceItem
{
/// <summary>
/// Gets or sets the id.
/// </summary>
/// <value>The id.</value>
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;
}
}
/// <summary>
/// Gets or sets the type of the location.
/// </summary>
@ -42,22 +19,5 @@ namespace MediaBrowser.Controller.Entities
return LocationType.Virtual;
}
}
/// <summary>
/// We don't resolve normally so need to fill this in
/// </summary>
public override string DisplayMediaType
{
get
{
return "CollectionFolder"; // Plug-in folders are collection folders
}
set
{
base.DisplayMediaType = value;
}
}
}
}

View File

@ -74,22 +74,6 @@ namespace MediaBrowser.Controller.Entities
}
}
/// <summary>
/// Ensure this has a value
/// </summary>
/// <value>The display type of the media.</value>
public override string DisplayMediaType
{
get
{
return base.DisplayMediaType ?? GetType().Name;
}
set
{
base.DisplayMediaType = value;
}
}
/// <summary>
/// The _root folder
/// </summary>

View File

@ -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;

View File

@ -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"
};
}
}

View File

@ -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;
}
}
}

View File

@ -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;
}