2012-07-12 06:55:27 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2012-08-18 08:22:54 +00:00
|
|
|
|
using System.Linq;
|
2012-07-12 06:55:27 +00:00
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.Model.Entities
|
|
|
|
|
{
|
2012-08-18 08:22:54 +00:00
|
|
|
|
public abstract class BaseItem : BaseEntity, IHasProviderIds
|
2012-07-12 06:55:27 +00:00
|
|
|
|
{
|
2012-08-18 19:38:27 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Goes up the tree to find the virtual folder parent
|
|
|
|
|
/// </summary>
|
|
|
|
|
public VirtualFolder VirtualFolder
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
var vf = this as VirtualFolder;
|
|
|
|
|
|
|
|
|
|
if (vf != null)
|
|
|
|
|
{
|
|
|
|
|
return vf;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Parent != null)
|
|
|
|
|
{
|
|
|
|
|
return Parent.VirtualFolder;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-07-20 02:22:44 +00:00
|
|
|
|
public string SortName { get; set; }
|
2012-07-12 06:55:27 +00:00
|
|
|
|
|
2012-07-20 02:22:44 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// When the item first debuted. For movies this could be premiere date, episodes would be first aired
|
|
|
|
|
/// </summary>
|
|
|
|
|
public DateTime? PremiereDate { get; set; }
|
|
|
|
|
|
|
|
|
|
public string Path { get; set; }
|
2012-07-15 20:27:07 +00:00
|
|
|
|
|
2012-07-12 06:55:27 +00:00
|
|
|
|
public Folder Parent { get; set; }
|
|
|
|
|
|
2012-07-20 02:22:44 +00:00
|
|
|
|
public string LogoImagePath { get; set; }
|
2012-08-18 08:22:54 +00:00
|
|
|
|
|
2012-07-20 02:22:44 +00:00
|
|
|
|
public string ArtImagePath { get; set; }
|
2012-08-18 08:22:54 +00:00
|
|
|
|
|
2012-07-20 02:22:44 +00:00
|
|
|
|
public string ThumbnailImagePath { get; set; }
|
2012-08-18 08:22:54 +00:00
|
|
|
|
|
2012-07-20 02:22:44 +00:00
|
|
|
|
public string BannerImagePath { get; set; }
|
2012-07-12 06:55:27 +00:00
|
|
|
|
|
2012-07-20 02:22:44 +00:00
|
|
|
|
public IEnumerable<string> BackdropImagePaths { get; set; }
|
2012-07-12 06:55:27 +00:00
|
|
|
|
|
2012-07-20 02:22:44 +00:00
|
|
|
|
public string OfficialRating { get; set; }
|
2012-08-17 13:16:50 +00:00
|
|
|
|
|
2012-07-20 02:22:44 +00:00
|
|
|
|
public string CustomRating { get; set; }
|
2012-07-12 06:55:27 +00:00
|
|
|
|
|
2012-07-20 02:22:44 +00:00
|
|
|
|
public string Overview { get; set; }
|
2012-08-18 08:22:54 +00:00
|
|
|
|
public IEnumerable<string> Taglines { get; set; }
|
2012-07-12 06:55:27 +00:00
|
|
|
|
|
2012-07-20 02:22:44 +00:00
|
|
|
|
public IEnumerable<PersonInfo> People { get; set; }
|
2012-07-12 06:55:27 +00:00
|
|
|
|
|
2012-07-20 02:22:44 +00:00
|
|
|
|
public IEnumerable<string> Studios { get; set; }
|
2012-07-12 06:55:27 +00:00
|
|
|
|
|
2012-07-20 02:22:44 +00:00
|
|
|
|
public IEnumerable<string> Genres { get; set; }
|
2012-07-12 06:55:27 +00:00
|
|
|
|
|
2012-07-20 02:22:44 +00:00
|
|
|
|
public string DisplayMediaType { get; set; }
|
2012-07-12 06:55:27 +00:00
|
|
|
|
|
2012-07-20 02:22:44 +00:00
|
|
|
|
public float? UserRating { get; set; }
|
2012-08-18 08:22:54 +00:00
|
|
|
|
public long? RunTimeTicks { get; set; }
|
2012-07-12 06:55:27 +00:00
|
|
|
|
|
2012-07-20 02:22:44 +00:00
|
|
|
|
public string AspectRatio { get; set; }
|
|
|
|
|
public int? ProductionYear { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// If the item is part of a series, this is it's number in the series.
|
|
|
|
|
/// This could be episode number, album track number, etc.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public int? IndexNumber { get; set; }
|
2012-07-12 06:55:27 +00:00
|
|
|
|
|
2012-07-20 02:22:44 +00:00
|
|
|
|
public IEnumerable<Video> LocalTrailers { get; set; }
|
|
|
|
|
|
|
|
|
|
public string TrailerUrl { get; set; }
|
2012-08-15 13:20:29 +00:00
|
|
|
|
|
|
|
|
|
public Dictionary<string, string> ProviderIds { get; set; }
|
|
|
|
|
|
2012-08-18 08:22:54 +00:00
|
|
|
|
public Dictionary<Guid, UserItemData> UserData { get; set; }
|
2012-08-15 13:20:29 +00:00
|
|
|
|
|
2012-08-18 08:22:54 +00:00
|
|
|
|
public UserItemData GetUserData(User user)
|
2012-08-15 13:20:29 +00:00
|
|
|
|
{
|
2012-08-18 08:22:54 +00:00
|
|
|
|
if (UserData == null || !UserData.ContainsKey(user.Id))
|
2012-08-15 13:20:29 +00:00
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-18 08:22:54 +00:00
|
|
|
|
return UserData[user.Id];
|
2012-08-15 13:20:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-08-18 08:22:54 +00:00
|
|
|
|
public void AddUserData(User user, UserItemData data)
|
2012-08-15 13:20:29 +00:00
|
|
|
|
{
|
2012-08-18 08:22:54 +00:00
|
|
|
|
if (UserData == null)
|
2012-08-15 13:20:29 +00:00
|
|
|
|
{
|
2012-08-18 08:22:54 +00:00
|
|
|
|
UserData = new Dictionary<Guid, UserItemData>();
|
2012-08-15 13:20:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-08-18 08:22:54 +00:00
|
|
|
|
UserData[user.Id] = data;
|
2012-08-15 13:20:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2012-08-18 08:22:54 +00:00
|
|
|
|
/// Determines if a given user has access to this item
|
2012-08-15 13:20:29 +00:00
|
|
|
|
/// </summary>
|
2012-08-18 08:22:54 +00:00
|
|
|
|
internal bool IsParentalAllowed(User user)
|
2012-08-15 13:20:29 +00:00
|
|
|
|
{
|
2012-08-18 08:22:54 +00:00
|
|
|
|
return true;
|
2012-08-15 13:20:29 +00:00
|
|
|
|
}
|
2012-08-17 17:37:26 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
2012-08-18 08:22:54 +00:00
|
|
|
|
/// Finds an item by ID, recursively
|
2012-08-17 17:37:26 +00:00
|
|
|
|
/// </summary>
|
2012-08-18 08:22:54 +00:00
|
|
|
|
public virtual BaseItem FindItemById(Guid id)
|
2012-08-17 17:37:26 +00:00
|
|
|
|
{
|
2012-08-18 08:22:54 +00:00
|
|
|
|
if (Id == id)
|
|
|
|
|
{
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (LocalTrailers != null)
|
|
|
|
|
{
|
|
|
|
|
return LocalTrailers.FirstOrDefault(i => i.Id == id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
2012-08-17 17:37:26 +00:00
|
|
|
|
}
|
2012-08-19 17:00:52 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Determines if the item is considered new based on user settings
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool IsRecentlyAdded(User user)
|
|
|
|
|
{
|
|
|
|
|
return (DateTime.Now - DateCreated).TotalDays < user.RecentItemDays;
|
|
|
|
|
}
|
2012-07-12 06:55:27 +00:00
|
|
|
|
}
|
|
|
|
|
}
|