BaseItem.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace MediaBrowser.Model.Entities
  5. {
  6. public abstract class BaseItem : BaseEntity, IHasProviderIds
  7. {
  8. public string SortName { get; set; }
  9. /// <summary>
  10. /// When the item first debuted. For movies this could be premiere date, episodes would be first aired
  11. /// </summary>
  12. public DateTime? PremiereDate { get; set; }
  13. public string Path { get; set; }
  14. public Folder Parent { get; set; }
  15. public string LogoImagePath { get; set; }
  16. public string ArtImagePath { get; set; }
  17. public string ThumbnailImagePath { get; set; }
  18. public string BannerImagePath { get; set; }
  19. public IEnumerable<string> BackdropImagePaths { get; set; }
  20. public string OfficialRating { get; set; }
  21. public string CustomRating { get; set; }
  22. public string Overview { get; set; }
  23. public IEnumerable<string> Taglines { get; set; }
  24. public IEnumerable<PersonInfo> People { get; set; }
  25. public IEnumerable<string> Studios { get; set; }
  26. public IEnumerable<string> Genres { get; set; }
  27. public string DisplayMediaType { get; set; }
  28. public float? UserRating { get; set; }
  29. public long? RunTimeTicks { get; set; }
  30. public string AspectRatio { get; set; }
  31. public int? ProductionYear { get; set; }
  32. /// <summary>
  33. /// If the item is part of a series, this is it's number in the series.
  34. /// This could be episode number, album track number, etc.
  35. /// </summary>
  36. public int? IndexNumber { get; set; }
  37. public IEnumerable<Video> LocalTrailers { get; set; }
  38. public string TrailerUrl { get; set; }
  39. public Dictionary<string, string> ProviderIds { get; set; }
  40. public Dictionary<Guid, UserItemData> UserData { get; set; }
  41. public UserItemData GetUserData(User user)
  42. {
  43. if (UserData == null || !UserData.ContainsKey(user.Id))
  44. {
  45. return null;
  46. }
  47. return UserData[user.Id];
  48. }
  49. public void AddUserData(User user, UserItemData data)
  50. {
  51. if (UserData == null)
  52. {
  53. UserData = new Dictionary<Guid, UserItemData>();
  54. }
  55. UserData[user.Id] = data;
  56. }
  57. /// <summary>
  58. /// Determines if a given user has access to this item
  59. /// </summary>
  60. internal bool IsParentalAllowed(User user)
  61. {
  62. return true;
  63. }
  64. /// <summary>
  65. /// Finds an item by ID, recursively
  66. /// </summary>
  67. public virtual BaseItem FindItemById(Guid id)
  68. {
  69. if (Id == id)
  70. {
  71. return this;
  72. }
  73. if (LocalTrailers != null)
  74. {
  75. return LocalTrailers.FirstOrDefault(i => i.Id == id);
  76. }
  77. return null;
  78. }
  79. }
  80. }