using MediaBrowser.Controller.Entities.Audio; using MediaBrowser.Controller.Providers; using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Entities; 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 { /// /// Gets or sets the album. /// /// The album. public string Album { get; set; } /// /// Gets or sets the budget. /// /// The budget. public double? Budget { get; set; } /// /// Gets or sets the revenue. /// /// The revenue. public double? Revenue { get; set; } public List ProductionLocations { get; set; } public List Artists { get; set; } public MusicVideo() { ProductionLocations = new List(); Artists = new List(); } [IgnoreDataMember] public List AllArtists { get { return Artists; } } /// /// TODO: Remove /// public string Artist { get { return Artists.FirstOrDefault(); } set { if (!string.IsNullOrEmpty(value) && !Artists.Contains(value, StringComparer.OrdinalIgnoreCase)) { Artists.Add(value); } } } /// /// Determines whether the specified name has artist. /// /// The name. /// true if the specified name has artist; otherwise, false. public bool HasArtist(string name) { return AllArtists.Contains(name, StringComparer.OrdinalIgnoreCase); } /// /// Gets the user data key. /// /// System.String. public override string GetUserDataKey() { return this.GetProviderId(MetadataProviders.Tmdb) ?? this.GetProviderId(MetadataProviders.Imdb) ?? base.GetUserDataKey(); } protected override bool GetBlockUnratedValue(UserPolicy config) { return config.BlockUnratedItems.Contains(UnratedItem.Music); } public MusicVideoInfo GetLookupInfo() { return GetItemLookupInfo(); } 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; } } }