diff options
Diffstat (limited to 'MediaBrowser.Controller/Entities/MusicVideo.cs')
| -rw-r--r-- | MediaBrowser.Controller/Entities/MusicVideo.cs | 79 |
1 files changed, 51 insertions, 28 deletions
diff --git a/MediaBrowser.Controller/Entities/MusicVideo.cs b/MediaBrowser.Controller/Entities/MusicVideo.cs index d36bfd7c4..4ca8cf1c5 100644 --- a/MediaBrowser.Controller/Entities/MusicVideo.cs +++ b/MediaBrowser.Controller/Entities/MusicVideo.cs @@ -6,18 +6,13 @@ using System; using System.Collections.Generic; using System.Linq; using System.Runtime.Serialization; +using MediaBrowser.Model.Users; namespace MediaBrowser.Controller.Entities { public class MusicVideo : Video, IHasArtist, IHasMusicGenres, IHasProductionLocations, IHasBudget, IHasLookupInfo<MusicVideoInfo> { /// <summary> - /// Gets or sets the artist. - /// </summary> - /// <value>The artist.</value> - public string Artist { get; set; } - - /// <summary> /// Gets or sets the album. /// </summary> /// <value>The album.</value> @@ -35,43 +30,35 @@ namespace MediaBrowser.Controller.Entities /// <value>The revenue.</value> public double? Revenue { get; set; } public List<string> ProductionLocations { get; set; } + public List<string> Artists { get; set; } public MusicVideo() { ProductionLocations = new List<string>(); + Artists = new List<string>(); } [IgnoreDataMember] - public List<string> Artists + public List<string> AllArtists { get { - var list = new List<string>(); - - if (!string.IsNullOrEmpty(Artist)) - { - list.Add(Artist); - } - - return list; - + return Artists; } } - [IgnoreDataMember] - public List<string> AllArtists + /// <summary> + /// TODO: Remove + /// </summary> + public string Artist { - get + get { return Artists.FirstOrDefault(); } + set { - var list = new List<string>(); - - if (!string.IsNullOrEmpty(Artist)) + if (!string.IsNullOrEmpty(value) && !Artists.Contains(value, StringComparer.OrdinalIgnoreCase)) { - list.Add(Artist); + Artists.Add(value); } - - return list; - } } @@ -82,7 +69,7 @@ namespace MediaBrowser.Controller.Entities /// <returns><c>true</c> if the specified name has artist; otherwise, <c>false</c>.</returns> public bool HasArtist(string name) { - return string.Equals(Artist, name, StringComparison.OrdinalIgnoreCase); + return AllArtists.Contains(name, StringComparer.OrdinalIgnoreCase); } /// <summary> @@ -94,7 +81,7 @@ namespace MediaBrowser.Controller.Entities return this.GetProviderId(MetadataProviders.Tmdb) ?? this.GetProviderId(MetadataProviders.Imdb) ?? base.GetUserDataKey(); } - protected override bool GetBlockUnratedValue(UserConfiguration config) + protected override bool GetBlockUnratedValue(UserPolicy config) { return config.BlockUnratedItems.Contains(UnratedItem.Music); } @@ -103,5 +90,41 @@ namespace MediaBrowser.Controller.Entities { return GetItemLookupInfo<MusicVideoInfo>(); } + + public override bool BeforeMetadataRefresh() + { + var hasChanges = base.BeforeMetadataRefresh(); + + if (!ProductionYear.HasValue) + { + var info = LibraryManager.ParseName(Name); + + var yearInName = info.Year; + + if (yearInName.HasValue) + { + ProductionYear = yearInName; + hasChanges = true; + } + else + { + // Try to get the year from the folder name + if (!IsInMixedFolder) + { + info = LibraryManager.ParseName(System.IO.Path.GetFileName(ContainingFolderPath)); + + yearInName = info.Year; + + if (yearInName.HasValue) + { + ProductionYear = yearInName; + hasChanges = true; + } + } + } + } + + return hasChanges; + } } } |
