From 45a58de53937816d535311a7c009829120a8c8e8 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 20 Nov 2015 23:57:47 -0500 Subject: [PATCH] fix merge conflict --- MediaBrowser.Controller/Entities/BaseItem.cs | 208 +++++-------------- 1 file changed, 51 insertions(+), 157 deletions(-) diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index a871b9822c..7086ac7437 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -24,7 +24,6 @@ using System.Runtime.Serialization; using System.Threading; using System.Threading.Tasks; using CommonIO; -using MediaBrowser.Model.LiveTv; namespace MediaBrowser.Controller.Entities { @@ -35,7 +34,6 @@ namespace MediaBrowser.Controller.Entities { protected BaseItem() { - Tags = new List(); Genres = new List(); Studios = new List(); ProviderIds = new Dictionary(StringComparer.OrdinalIgnoreCase); @@ -46,7 +44,7 @@ namespace MediaBrowser.Controller.Entities /// /// The supported image extensions /// - public static readonly string[] SupportedImageExtensions = { ".png", ".jpg", ".jpeg", ".tbn" }; + public static readonly string[] SupportedImageExtensions = { ".png", ".jpg", ".jpeg" }; public static readonly List SupportedImageExtensionsList = SupportedImageExtensions.ToList(); @@ -105,8 +103,7 @@ namespace MediaBrowser.Controller.Entities /// Gets or sets the name. /// /// The name. - [IgnoreDataMember] - public virtual string Name + public string Name { get { @@ -125,23 +122,14 @@ namespace MediaBrowser.Controller.Entities /// Gets or sets the id. /// /// The id. - [IgnoreDataMember] public Guid Id { get; set; } /// /// Gets or sets a value indicating whether this instance is hd. /// /// true if this instance is hd; otherwise, false. - [IgnoreDataMember] public bool? IsHD { get; set; } - /// - /// Gets or sets the audio. - /// - /// The audio. - [IgnoreDataMember] - public ProgramAudio? Audio { get; set; } - /// /// Return the id that should be used to key display prefs for this item. /// Default is based on the type for everything except actual generic folders. @@ -161,7 +149,6 @@ namespace MediaBrowser.Controller.Entities /// Gets or sets the path. /// /// The path. - [IgnoreDataMember] public virtual string Path { get; set; } [IgnoreDataMember] @@ -186,7 +173,7 @@ namespace MediaBrowser.Controller.Entities } /// - /// If this content came from an external service, the id of the content on that service + /// Id of the program. /// [IgnoreDataMember] public string ExternalId @@ -214,6 +201,11 @@ namespace MediaBrowser.Controller.Entities } } + public virtual bool IsHiddenFromUser(User user) + { + return false; + } + [IgnoreDataMember] public virtual bool IsOwnedItem { @@ -333,14 +325,12 @@ namespace MediaBrowser.Controller.Entities /// Gets or sets the date created. /// /// The date created. - [IgnoreDataMember] public DateTime DateCreated { get; set; } /// /// Gets or sets the date modified. /// /// The date modified. - [IgnoreDataMember] public DateTime DateModified { get; set; } public DateTime DateLastSaved { get; set; } @@ -417,7 +407,6 @@ namespace MediaBrowser.Controller.Entities /// Gets or sets the name of the forced sort. /// /// The name of the forced sort. - [IgnoreDataMember] public string ForcedSortName { get { return _forcedSortName; } @@ -458,7 +447,10 @@ namespace MediaBrowser.Controller.Entities { var idString = Id.ToString("N"); - basePath = System.IO.Path.Combine(basePath, "library"); + if (ConfigurationManager.Configuration.EnableLibraryMetadataSubFolder) + { + basePath = System.IO.Path.Combine(basePath, "library"); + } return System.IO.Path.Combine(basePath, idString.Substring(0, 2), idString); } @@ -501,7 +493,6 @@ namespace MediaBrowser.Controller.Entities return sortable; } - [IgnoreDataMember] public Guid ParentId { get; set; } /// @@ -511,7 +502,15 @@ namespace MediaBrowser.Controller.Entities [IgnoreDataMember] public Folder Parent { - get { return GetParent() as Folder; } + get + { + if (ParentId != Guid.Empty) + { + return LibraryManager.GetItemById(ParentId) as Folder; + } + + return null; + } set { @@ -526,28 +525,16 @@ namespace MediaBrowser.Controller.Entities [IgnoreDataMember] public IEnumerable Parents { - get { return GetParents().OfType(); } - } - - public BaseItem GetParent() - { - if (ParentId != Guid.Empty) + get { - return LibraryManager.GetItemById(ParentId); - } + var parent = Parent; - return null; - } + while (parent != null) + { + yield return parent; - public IEnumerable GetParents() - { - var parent = GetParent(); - - while (parent != null) - { - yield return parent; - - parent = parent.GetParent(); + parent = parent.Parent; + } } } @@ -559,20 +546,19 @@ namespace MediaBrowser.Controller.Entities public T FindParent() where T : Folder { - return GetParents().OfType().FirstOrDefault(); + return Parents.OfType().FirstOrDefault(); } [IgnoreDataMember] public virtual BaseItem DisplayParent { - get { return GetParent(); } + get { return Parent; } } /// /// When the item first debuted. For movies this could be premiere date, episodes would be first aired /// /// The premiere date. - [IgnoreDataMember] public DateTime? PremiereDate { get; set; } /// @@ -586,35 +572,31 @@ namespace MediaBrowser.Controller.Entities /// Gets or sets the display type of the media. /// /// The display type of the media. - [IgnoreDataMember] public string DisplayMediaType { get; set; } /// /// Gets or sets the official rating. /// /// The official rating. - [IgnoreDataMember] public string OfficialRating { get; set; } /// /// Gets or sets the official rating description. /// /// The official rating description. - [IgnoreDataMember] public string OfficialRatingDescription { get; set; } /// /// Gets or sets the custom rating. /// /// The custom rating. - [IgnoreDataMember] + //[IgnoreDataMember] public string CustomRating { get; set; } /// /// Gets or sets the overview. /// /// The overview. - [IgnoreDataMember] public string Overview { get; set; } /// @@ -627,48 +609,37 @@ namespace MediaBrowser.Controller.Entities /// Gets or sets the genres. /// /// The genres. - [IgnoreDataMember] public List Genres { get; set; } - /// - /// Gets or sets the tags. - /// - /// The tags. - public List Tags { get; set; } - /// /// Gets or sets the home page URL. /// /// The home page URL. - [IgnoreDataMember] public string HomePageUrl { get; set; } /// /// Gets or sets the community rating. /// /// The community rating. - [IgnoreDataMember] + //[IgnoreDataMember] public float? CommunityRating { get; set; } /// /// Gets or sets the community rating vote count. /// /// The community rating vote count. - [IgnoreDataMember] public int? VoteCount { get; set; } /// /// Gets or sets the run time ticks. /// /// The run time ticks. - [IgnoreDataMember] public long? RunTimeTicks { get; set; } /// /// Gets or sets the production year. /// /// The production year. - [IgnoreDataMember] public int? ProductionYear { get; set; } /// @@ -676,34 +647,19 @@ namespace MediaBrowser.Controller.Entities /// This could be episode number, album track number, etc. /// /// The index number. - [IgnoreDataMember] + //[IgnoreDataMember] public int? IndexNumber { get; set; } /// /// For an episode this could be the season number, or for a song this could be the disc number. /// /// The parent index number. - [IgnoreDataMember] public int? ParentIndexNumber { get; set; } [IgnoreDataMember] - public string OfficialRatingForComparison + public virtual string OfficialRatingForComparison { - get - { - if (!string.IsNullOrWhiteSpace(OfficialRating)) - { - return OfficialRating; - } - - var parent = DisplayParent; - if (parent != null) - { - return parent.OfficialRatingForComparison; - } - - return null; - } + get { return OfficialRating; } } [IgnoreDataMember] @@ -865,7 +821,7 @@ namespace MediaBrowser.Controller.Entities [IgnoreDataMember] protected virtual bool SupportsOwnedItems { - get { return IsFolder || GetParent() != null; } + get { return IsFolder || Parent != null; } } [IgnoreDataMember] @@ -890,7 +846,7 @@ namespace MediaBrowser.Controller.Entities var localTrailersChanged = false; - if (LocationType == LocationType.FileSystem && GetParent() != null) + if (LocationType == LocationType.FileSystem && Parent != null) { var hasThemeMedia = this as IHasThemeMedia; if (hasThemeMedia != null) @@ -1052,7 +1008,7 @@ namespace MediaBrowser.Controller.Entities if (string.IsNullOrWhiteSpace(lang)) { - lang = GetParents() + lang = Parents .Select(i => i.PreferredMetadataLanguage) .FirstOrDefault(i => !string.IsNullOrWhiteSpace(i)); } @@ -1082,7 +1038,7 @@ namespace MediaBrowser.Controller.Entities if (string.IsNullOrWhiteSpace(lang)) { - lang = GetParents() + lang = Parents .Select(i => i.PreferredMetadataCountryCode) .FirstOrDefault(i => !string.IsNullOrWhiteSpace(i)); } @@ -1163,23 +1119,6 @@ namespace MediaBrowser.Controller.Entities } public int? GetParentalRatingValue() - { - var rating = CustomRating; - - if (string.IsNullOrWhiteSpace(rating)) - { - rating = OfficialRating; - } - - if (string.IsNullOrWhiteSpace(rating)) - { - return null; - } - - return LocalizationManager.GetRatingLevel(rating); - } - - public int? GetInheritedParentalRatingValue() { var rating = CustomRatingForComparison; @@ -1217,11 +1156,6 @@ namespace MediaBrowser.Controller.Entities return true; } - public virtual UnratedItem GetBlockUnratedType() - { - return UnratedItem.Other; - } - /// /// Gets the block unrated value. /// @@ -1240,7 +1174,7 @@ namespace MediaBrowser.Controller.Entities return false; } - return config.BlockUnratedItems.Contains(GetBlockUnratedType()); + return config.BlockUnratedItems.Contains(UnratedItem.Other); } /// @@ -1272,14 +1206,14 @@ namespace MediaBrowser.Controller.Entities return false; } - if (GetParents().Any(i => !i.IsVisible(user))) + if (Parents.Any(i => !i.IsVisible(user))) { return false; } if (checkFolders) { - var topParent = GetParents().LastOrDefault() ?? this; + var topParent = Parents.LastOrDefault() ?? this; if (string.IsNullOrWhiteSpace(topParent.Path)) { @@ -1373,6 +1307,15 @@ namespace MediaBrowser.Controller.Entities return null; } + /// + /// Adds a person to the item + /// + /// The person. + /// + public void AddPerson(PersonInfo person) + { + } + /// /// Adds a studio to the item /// @@ -1931,54 +1874,5 @@ namespace MediaBrowser.Controller.Entities DateLastSaved.Ticks.ToString(CultureInfo.InvariantCulture) }; } - - public virtual IEnumerable GetAncestorIds() - { - return GetParents().Select(i => i.Id).Concat(LibraryManager.GetCollectionFolders(this).Select(i => i.Id)); - } - - public BaseItem GetTopParent() - { - if (IsTopParent) - { - return this; - } - - return GetParents().FirstOrDefault(i => i.IsTopParent); - } - - [IgnoreDataMember] - public virtual bool IsTopParent - { - get - { - if (GetParent() is AggregateFolder || this is Channel || this is BasePluginFolder) - { - return true; - } - - var view = this as UserView; - if (view != null && string.Equals(view.ViewType, CollectionType.LiveTv, StringComparison.OrdinalIgnoreCase)) - { - return true; - } - - return false; - } - } - - [IgnoreDataMember] - public virtual bool SupportsAncestors - { - get - { - return true; - } - } - - public virtual IEnumerable GetIdsForAncestorQuery() - { - return new[] { Id }; - } } }