diff options
Diffstat (limited to 'MediaBrowser.Controller/Entities')
| -rw-r--r-- | MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs | 58 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Entities/BaseItem.cs | 57 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Entities/User.cs | 18 |
3 files changed, 87 insertions, 46 deletions
diff --git a/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs b/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs index e9f222016..7b64c0e85 100644 --- a/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs +++ b/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.Linq; using System.Runtime.Serialization; +using MediaBrowser.Model.Entities; namespace MediaBrowser.Controller.Entities.Audio { @@ -53,30 +54,6 @@ namespace MediaBrowser.Controller.Entities.Audio } /// <summary> - /// Override to point to first child (song) if not explicitly defined - /// </summary> - /// <value>The primary image path.</value> - [IgnoreDataMember] - public override string PrimaryImagePath - { - get - { - if (base.PrimaryImagePath == null) - { - var child = Children.FirstOrDefault(); - - return child == null ? base.PrimaryImagePath : child.PrimaryImagePath; - } - - return base.PrimaryImagePath; - } - set - { - base.PrimaryImagePath = value; - } - } - - /// <summary> /// Override to point to first child (song) /// </summary> /// <value>The production year.</value> @@ -131,6 +108,39 @@ namespace MediaBrowser.Controller.Entities.Audio } /// <summary> + /// Gets or sets the images. + /// </summary> + /// <value>The images.</value> + public override Dictionary<string, string> Images + { + get + { + var images = base.Images; + string primaryImagePath; + + if (images == null || !images.TryGetValue(ImageType.Primary.ToString(), out primaryImagePath)) + { + var image = Children.Select(c => c.PrimaryImagePath).FirstOrDefault(c => !string.IsNullOrEmpty(c)); + + if (!string.IsNullOrEmpty(image)) + { + if (images == null) + { + images = new Dictionary<string, string>(); + } + images[ImageType.Primary.ToString()] = image; + } + } + + return images; + } + set + { + base.Images = value; + } + } + + /// <summary> /// Creates the name of the sort. /// </summary> /// <returns>System.String.</returns> diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index 411190d77..7587a8a5a 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -69,7 +69,7 @@ namespace MediaBrowser.Controller.Entities /// </summary> /// <value>The primary image path.</value> [IgnoreDataMember] - public virtual string PrimaryImagePath + public string PrimaryImagePath { get { return GetImage(ImageType.Primary); } set { SetImage(ImageType.Primary, value); } @@ -79,7 +79,7 @@ namespace MediaBrowser.Controller.Entities /// Gets or sets the images. /// </summary> /// <value>The images.</value> - public Dictionary<string, string> Images { get; set; } + public virtual Dictionary<string, string> Images { get; set; } /// <summary> /// Gets or sets the date created. @@ -547,6 +547,12 @@ namespace MediaBrowser.Controller.Entities public virtual List<string> Studios { get; set; } /// <summary> + /// Gets or sets the publishers. + /// </summary> + /// <value>The publishers.</value> + public virtual List<string> Publishers { get; set; } + + /// <summary> /// Gets or sets the genres. /// </summary> /// <value>The genres.</value> @@ -996,7 +1002,7 @@ namespace MediaBrowser.Controller.Entities { if (string.IsNullOrWhiteSpace(name)) { - throw new ArgumentNullException(); + throw new ArgumentNullException("name"); } if (Studios == null) @@ -1011,6 +1017,47 @@ namespace MediaBrowser.Controller.Entities } /// <summary> + /// Adds the publishers. + /// </summary> + /// <param name="publishers">The publishers.</param> + /// <exception cref="System.ArgumentNullException"></exception> + public void AddPublishers(IEnumerable<string> publishers) + { + if (publishers == null) + { + throw new ArgumentNullException(); + } + + foreach (var name in publishers) + { + AddPublisher(name); + } + } + + /// <summary> + /// Adds the publisher. + /// </summary> + /// <param name="name">The name.</param> + /// <exception cref="System.ArgumentNullException">name</exception> + public void AddPublisher(string name) + { + if (string.IsNullOrWhiteSpace(name)) + { + throw new ArgumentNullException("name"); + } + + if (Publishers == null) + { + Publishers = new List<string>(); + } + + if (!Publishers.Contains(name, StringComparer.OrdinalIgnoreCase)) + { + Publishers.Add(name); + } + } + + /// <summary> /// Adds a tagline to the item /// </summary> /// <param name="name">The name.</param> @@ -1019,7 +1066,7 @@ namespace MediaBrowser.Controller.Entities { if (string.IsNullOrWhiteSpace(name)) { - throw new ArgumentNullException(); + throw new ArgumentNullException("name"); } if (Taglines == null) @@ -1042,7 +1089,7 @@ namespace MediaBrowser.Controller.Entities { if (string.IsNullOrWhiteSpace(url)) { - throw new ArgumentNullException(); + throw new ArgumentNullException("url"); } if (TrailerUrls == null) diff --git a/MediaBrowser.Controller/Entities/User.cs b/MediaBrowser.Controller/Entities/User.cs index 690f97605..954dfb05f 100644 --- a/MediaBrowser.Controller/Entities/User.cs +++ b/MediaBrowser.Controller/Entities/User.cs @@ -125,7 +125,7 @@ namespace MediaBrowser.Controller.Entities { get { - LazyInitializer.EnsureInitialized(ref _rootFolder, ref _userRootFolderInitialized, ref _userRootFolderSyncLock, () => (UserRootFolder)LibraryManager.ResolvePath(RootFolderPath)); + LazyInitializer.EnsureInitialized(ref _rootFolder, ref _userRootFolderInitialized, ref _userRootFolderSyncLock, () => LibraryManager.GetUserRootFolder(RootFolderPath)); return _rootFolder; } private set @@ -219,22 +219,6 @@ namespace MediaBrowser.Controller.Entities } /// <summary> - /// Validates only the collection folders for a User and goes no further - /// </summary> - /// <param name="cancellationToken">The cancellation token.</param> - /// <param name="progress">The progress.</param> - /// <returns>Task.</returns> - public async Task ValidateCollectionFolders(IProgress<double> progress, CancellationToken cancellationToken) - { - Logger.Info("Validating collection folders for {0}", Name); - await RootFolder.RefreshMetadata(cancellationToken).ConfigureAwait(false); - - cancellationToken.ThrowIfCancellationRequested(); - - await RootFolder.ValidateChildren(progress, cancellationToken, recursive: false).ConfigureAwait(false); - } - - /// <summary> /// Renames the user. /// </summary> /// <param name="newName">The new name.</param> |
