restore changes

This commit is contained in:
Luke Pulverenti 2016-01-12 15:07:33 -05:00
parent 1e00ed688f
commit d9e0265f12
2 changed files with 182 additions and 83 deletions

View File

@ -1,5 +1,4 @@
using MediaBrowser.Common.Extensions; using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.IO;
using MediaBrowser.Controller.Channels; using MediaBrowser.Controller.Channels;
using MediaBrowser.Controller.Collections; using MediaBrowser.Controller.Collections;
using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Configuration;
@ -24,6 +23,7 @@ using System.Runtime.Serialization;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using CommonIO; using CommonIO;
using MediaBrowser.Model.LiveTv;
namespace MediaBrowser.Controller.Entities namespace MediaBrowser.Controller.Entities
{ {
@ -34,6 +34,7 @@ namespace MediaBrowser.Controller.Entities
{ {
protected BaseItem() protected BaseItem()
{ {
Tags = new List<string>();
Genres = new List<string>(); Genres = new List<string>();
Studios = new List<string>(); Studios = new List<string>();
ProviderIds = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); ProviderIds = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
@ -44,7 +45,7 @@ namespace MediaBrowser.Controller.Entities
/// <summary> /// <summary>
/// The supported image extensions /// The supported image extensions
/// </summary> /// </summary>
public static readonly string[] SupportedImageExtensions = { ".png", ".jpg", ".jpeg" }; public static readonly string[] SupportedImageExtensions = { ".png", ".jpg", ".jpeg", ".tbn", ".gif" };
public static readonly List<string> SupportedImageExtensionsList = SupportedImageExtensions.ToList(); public static readonly List<string> SupportedImageExtensionsList = SupportedImageExtensions.ToList();
@ -103,7 +104,8 @@ namespace MediaBrowser.Controller.Entities
/// Gets or sets the name. /// Gets or sets the name.
/// </summary> /// </summary>
/// <value>The name.</value> /// <value>The name.</value>
public string Name [IgnoreDataMember]
public virtual string Name
{ {
get get
{ {
@ -122,14 +124,23 @@ namespace MediaBrowser.Controller.Entities
/// Gets or sets the id. /// Gets or sets the id.
/// </summary> /// </summary>
/// <value>The id.</value> /// <value>The id.</value>
[IgnoreDataMember]
public Guid Id { get; set; } public Guid Id { get; set; }
/// <summary> /// <summary>
/// Gets or sets a value indicating whether this instance is hd. /// Gets or sets a value indicating whether this instance is hd.
/// </summary> /// </summary>
/// <value><c>true</c> if this instance is hd; otherwise, <c>false</c>.</value> /// <value><c>true</c> if this instance is hd; otherwise, <c>false</c>.</value>
[IgnoreDataMember]
public bool? IsHD { get; set; } public bool? IsHD { get; set; }
/// <summary>
/// Gets or sets the audio.
/// </summary>
/// <value>The audio.</value>
[IgnoreDataMember]
public ProgramAudio? Audio { get; set; }
/// <summary> /// <summary>
/// Return the id that should be used to key display prefs for this item. /// 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. /// Default is based on the type for everything except actual generic folders.
@ -149,6 +160,7 @@ namespace MediaBrowser.Controller.Entities
/// Gets or sets the path. /// Gets or sets the path.
/// </summary> /// </summary>
/// <value>The path.</value> /// <value>The path.</value>
[IgnoreDataMember]
public virtual string Path { get; set; } public virtual string Path { get; set; }
[IgnoreDataMember] [IgnoreDataMember]
@ -173,7 +185,7 @@ namespace MediaBrowser.Controller.Entities
} }
/// <summary> /// <summary>
/// Id of the program. /// If this content came from an external service, the id of the content on that service
/// </summary> /// </summary>
[IgnoreDataMember] [IgnoreDataMember]
public string ExternalId public string ExternalId
@ -201,11 +213,6 @@ namespace MediaBrowser.Controller.Entities
} }
} }
public virtual bool IsHiddenFromUser(User user)
{
return false;
}
[IgnoreDataMember] [IgnoreDataMember]
public virtual bool IsOwnedItem public virtual bool IsOwnedItem
{ {
@ -325,12 +332,14 @@ namespace MediaBrowser.Controller.Entities
/// Gets or sets the date created. /// Gets or sets the date created.
/// </summary> /// </summary>
/// <value>The date created.</value> /// <value>The date created.</value>
[IgnoreDataMember]
public DateTime DateCreated { get; set; } public DateTime DateCreated { get; set; }
/// <summary> /// <summary>
/// Gets or sets the date modified. /// Gets or sets the date modified.
/// </summary> /// </summary>
/// <value>The date modified.</value> /// <value>The date modified.</value>
[IgnoreDataMember]
public DateTime DateModified { get; set; } public DateTime DateModified { get; set; }
public DateTime DateLastSaved { get; set; } public DateTime DateLastSaved { get; set; }
@ -407,6 +416,7 @@ namespace MediaBrowser.Controller.Entities
/// Gets or sets the name of the forced sort. /// Gets or sets the name of the forced sort.
/// </summary> /// </summary>
/// <value>The name of the forced sort.</value> /// <value>The name of the forced sort.</value>
[IgnoreDataMember]
public string ForcedSortName public string ForcedSortName
{ {
get { return _forcedSortName; } get { return _forcedSortName; }
@ -447,10 +457,7 @@ namespace MediaBrowser.Controller.Entities
{ {
var idString = Id.ToString("N"); var idString = Id.ToString("N");
if (ConfigurationManager.Configuration.EnableLibraryMetadataSubFolder)
{
basePath = System.IO.Path.Combine(basePath, "library"); basePath = System.IO.Path.Combine(basePath, "library");
}
return System.IO.Path.Combine(basePath, idString.Substring(0, 2), idString); return System.IO.Path.Combine(basePath, idString.Substring(0, 2), idString);
} }
@ -493,6 +500,7 @@ namespace MediaBrowser.Controller.Entities
return sortable; return sortable;
} }
[IgnoreDataMember]
public Guid ParentId { get; set; } public Guid ParentId { get; set; }
/// <summary> /// <summary>
@ -502,15 +510,7 @@ namespace MediaBrowser.Controller.Entities
[IgnoreDataMember] [IgnoreDataMember]
public Folder Parent public Folder Parent
{ {
get get { return GetParent() as Folder; }
{
if (ParentId != Guid.Empty)
{
return LibraryManager.GetItemById(ParentId) as Folder;
}
return null;
}
set set
{ {
@ -525,16 +525,28 @@ namespace MediaBrowser.Controller.Entities
[IgnoreDataMember] [IgnoreDataMember]
public IEnumerable<Folder> Parents public IEnumerable<Folder> Parents
{ {
get get { return GetParents().OfType<Folder>(); }
}
public BaseItem GetParent()
{ {
var parent = Parent; if (ParentId != Guid.Empty)
{
return LibraryManager.GetItemById(ParentId);
}
return null;
}
public IEnumerable<BaseItem> GetParents()
{
var parent = GetParent();
while (parent != null) while (parent != null)
{ {
yield return parent; yield return parent;
parent = parent.Parent; parent = parent.GetParent();
}
} }
} }
@ -546,19 +558,20 @@ namespace MediaBrowser.Controller.Entities
public T FindParent<T>() public T FindParent<T>()
where T : Folder where T : Folder
{ {
return Parents.OfType<T>().FirstOrDefault(); return GetParents().OfType<T>().FirstOrDefault();
} }
[IgnoreDataMember] [IgnoreDataMember]
public virtual BaseItem DisplayParent public virtual BaseItem DisplayParent
{ {
get { return Parent; } get { return GetParent(); }
} }
/// <summary> /// <summary>
/// When the item first debuted. For movies this could be premiere date, episodes would be first aired /// When the item first debuted. For movies this could be premiere date, episodes would be first aired
/// </summary> /// </summary>
/// <value>The premiere date.</value> /// <value>The premiere date.</value>
[IgnoreDataMember]
public DateTime? PremiereDate { get; set; } public DateTime? PremiereDate { get; set; }
/// <summary> /// <summary>
@ -572,31 +585,35 @@ namespace MediaBrowser.Controller.Entities
/// Gets or sets the display type of the media. /// Gets or sets the display type of the media.
/// </summary> /// </summary>
/// <value>The display type of the media.</value> /// <value>The display type of the media.</value>
[IgnoreDataMember]
public string DisplayMediaType { get; set; } public string DisplayMediaType { get; set; }
/// <summary> /// <summary>
/// Gets or sets the official rating. /// Gets or sets the official rating.
/// </summary> /// </summary>
/// <value>The official rating.</value> /// <value>The official rating.</value>
[IgnoreDataMember]
public string OfficialRating { get; set; } public string OfficialRating { get; set; }
/// <summary> /// <summary>
/// Gets or sets the official rating description. /// Gets or sets the official rating description.
/// </summary> /// </summary>
/// <value>The official rating description.</value> /// <value>The official rating description.</value>
[IgnoreDataMember]
public string OfficialRatingDescription { get; set; } public string OfficialRatingDescription { get; set; }
/// <summary> /// <summary>
/// Gets or sets the custom rating. /// Gets or sets the custom rating.
/// </summary> /// </summary>
/// <value>The custom rating.</value> /// <value>The custom rating.</value>
//[IgnoreDataMember] [IgnoreDataMember]
public string CustomRating { get; set; } public string CustomRating { get; set; }
/// <summary> /// <summary>
/// Gets or sets the overview. /// Gets or sets the overview.
/// </summary> /// </summary>
/// <value>The overview.</value> /// <value>The overview.</value>
[IgnoreDataMember]
public string Overview { get; set; } public string Overview { get; set; }
/// <summary> /// <summary>
@ -609,37 +626,48 @@ namespace MediaBrowser.Controller.Entities
/// Gets or sets the genres. /// Gets or sets the genres.
/// </summary> /// </summary>
/// <value>The genres.</value> /// <value>The genres.</value>
[IgnoreDataMember]
public List<string> Genres { get; set; } public List<string> Genres { get; set; }
/// <summary>
/// Gets or sets the tags.
/// </summary>
/// <value>The tags.</value>
public List<string> Tags { get; set; }
/// <summary> /// <summary>
/// Gets or sets the home page URL. /// Gets or sets the home page URL.
/// </summary> /// </summary>
/// <value>The home page URL.</value> /// <value>The home page URL.</value>
[IgnoreDataMember]
public string HomePageUrl { get; set; } public string HomePageUrl { get; set; }
/// <summary> /// <summary>
/// Gets or sets the community rating. /// Gets or sets the community rating.
/// </summary> /// </summary>
/// <value>The community rating.</value> /// <value>The community rating.</value>
//[IgnoreDataMember] [IgnoreDataMember]
public float? CommunityRating { get; set; } public float? CommunityRating { get; set; }
/// <summary> /// <summary>
/// Gets or sets the community rating vote count. /// Gets or sets the community rating vote count.
/// </summary> /// </summary>
/// <value>The community rating vote count.</value> /// <value>The community rating vote count.</value>
[IgnoreDataMember]
public int? VoteCount { get; set; } public int? VoteCount { get; set; }
/// <summary> /// <summary>
/// Gets or sets the run time ticks. /// Gets or sets the run time ticks.
/// </summary> /// </summary>
/// <value>The run time ticks.</value> /// <value>The run time ticks.</value>
[IgnoreDataMember]
public long? RunTimeTicks { get; set; } public long? RunTimeTicks { get; set; }
/// <summary> /// <summary>
/// Gets or sets the production year. /// Gets or sets the production year.
/// </summary> /// </summary>
/// <value>The production year.</value> /// <value>The production year.</value>
[IgnoreDataMember]
public int? ProductionYear { get; set; } public int? ProductionYear { get; set; }
/// <summary> /// <summary>
@ -647,19 +675,34 @@ namespace MediaBrowser.Controller.Entities
/// This could be episode number, album track number, etc. /// This could be episode number, album track number, etc.
/// </summary> /// </summary>
/// <value>The index number.</value> /// <value>The index number.</value>
//[IgnoreDataMember] [IgnoreDataMember]
public int? IndexNumber { get; set; } public int? IndexNumber { get; set; }
/// <summary> /// <summary>
/// For an episode this could be the season number, or for a song this could be the disc number. /// For an episode this could be the season number, or for a song this could be the disc number.
/// </summary> /// </summary>
/// <value>The parent index number.</value> /// <value>The parent index number.</value>
[IgnoreDataMember]
public int? ParentIndexNumber { get; set; } public int? ParentIndexNumber { get; set; }
[IgnoreDataMember] [IgnoreDataMember]
public virtual string OfficialRatingForComparison public string OfficialRatingForComparison
{ {
get { return OfficialRating; } get
{
if (!string.IsNullOrWhiteSpace(OfficialRating))
{
return OfficialRating;
}
var parent = DisplayParent;
if (parent != null)
{
return parent.OfficialRatingForComparison;
}
return null;
}
} }
[IgnoreDataMember] [IgnoreDataMember]
@ -821,7 +864,7 @@ namespace MediaBrowser.Controller.Entities
[IgnoreDataMember] [IgnoreDataMember]
protected virtual bool SupportsOwnedItems protected virtual bool SupportsOwnedItems
{ {
get { return IsFolder || Parent != null; } get { return IsFolder || GetParent() != null; }
} }
[IgnoreDataMember] [IgnoreDataMember]
@ -846,7 +889,7 @@ namespace MediaBrowser.Controller.Entities
var localTrailersChanged = false; var localTrailersChanged = false;
if (LocationType == LocationType.FileSystem && Parent != null) if (LocationType == LocationType.FileSystem && GetParent() != null)
{ {
var hasThemeMedia = this as IHasThemeMedia; var hasThemeMedia = this as IHasThemeMedia;
if (hasThemeMedia != null) if (hasThemeMedia != null)
@ -1008,7 +1051,7 @@ namespace MediaBrowser.Controller.Entities
if (string.IsNullOrWhiteSpace(lang)) if (string.IsNullOrWhiteSpace(lang))
{ {
lang = Parents lang = GetParents()
.Select(i => i.PreferredMetadataLanguage) .Select(i => i.PreferredMetadataLanguage)
.FirstOrDefault(i => !string.IsNullOrWhiteSpace(i)); .FirstOrDefault(i => !string.IsNullOrWhiteSpace(i));
} }
@ -1038,7 +1081,7 @@ namespace MediaBrowser.Controller.Entities
if (string.IsNullOrWhiteSpace(lang)) if (string.IsNullOrWhiteSpace(lang))
{ {
lang = Parents lang = GetParents()
.Select(i => i.PreferredMetadataCountryCode) .Select(i => i.PreferredMetadataCountryCode)
.FirstOrDefault(i => !string.IsNullOrWhiteSpace(i)); .FirstOrDefault(i => !string.IsNullOrWhiteSpace(i));
} }
@ -1119,6 +1162,23 @@ namespace MediaBrowser.Controller.Entities
} }
public int? GetParentalRatingValue() 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; var rating = CustomRatingForComparison;
@ -1156,6 +1216,11 @@ namespace MediaBrowser.Controller.Entities
return true; return true;
} }
public virtual UnratedItem GetBlockUnratedType()
{
return UnratedItem.Other;
}
/// <summary> /// <summary>
/// Gets the block unrated value. /// Gets the block unrated value.
/// </summary> /// </summary>
@ -1174,7 +1239,7 @@ namespace MediaBrowser.Controller.Entities
return false; return false;
} }
return config.BlockUnratedItems.Contains(UnratedItem.Other); return config.BlockUnratedItems.Contains(GetBlockUnratedType());
} }
/// <summary> /// <summary>
@ -1206,14 +1271,14 @@ namespace MediaBrowser.Controller.Entities
return false; return false;
} }
if (Parents.Any(i => !i.IsVisible(user))) if (GetParents().Any(i => !i.IsVisible(user)))
{ {
return false; return false;
} }
if (checkFolders) if (checkFolders)
{ {
var topParent = Parents.LastOrDefault() ?? this; var topParent = GetParents().LastOrDefault() ?? this;
if (string.IsNullOrWhiteSpace(topParent.Path)) if (string.IsNullOrWhiteSpace(topParent.Path))
{ {
@ -1307,15 +1372,6 @@ namespace MediaBrowser.Controller.Entities
return null; return null;
} }
/// <summary>
/// Adds a person to the item
/// </summary>
/// <param name="person">The person.</param>
/// <exception cref="System.ArgumentNullException"></exception>
public void AddPerson(PersonInfo person)
{
}
/// <summary> /// <summary>
/// Adds a studio to the item /// Adds a studio to the item
/// </summary> /// </summary>
@ -1875,5 +1931,54 @@ namespace MediaBrowser.Controller.Entities
DateLastSaved.Ticks.ToString(CultureInfo.InvariantCulture) DateLastSaved.Ticks.ToString(CultureInfo.InvariantCulture)
}; };
} }
public virtual IEnumerable<Guid> 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<Guid> GetIdsForAncestorQuery()
{
return new[] { Id };
}
} }
} }

View File

@ -62,12 +62,6 @@ namespace MediaBrowser.Model.Configuration
/// <value><c>true</c> if this instance is port authorized; otherwise, <c>false</c>.</value> /// <value><c>true</c> if this instance is port authorized; otherwise, <c>false</c>.</value>
public bool IsPortAuthorized { get; set; } public bool IsPortAuthorized { get; set; }
/// <summary>
/// Gets or sets a value indicating whether [enable high quality image scaling].
/// </summary>
/// <value><c>true</c> if [enable high quality image scaling]; otherwise, <c>false</c>.</value>
public bool EnableHighQualityImageScaling { get; set; }
/// <summary> /// <summary>
/// Gets or sets the item by name path. /// Gets or sets the item by name path.
/// </summary> /// </summary>