2
0

LiveTvProgram.cs 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. using MediaBrowser.Controller.Entities;
  2. using MediaBrowser.Controller.Entities.Movies;
  3. using MediaBrowser.Controller.Providers;
  4. using MediaBrowser.Model.Configuration;
  5. using MediaBrowser.Model.LiveTv;
  6. using System;
  7. using System.Runtime.Serialization;
  8. namespace MediaBrowser.Controller.LiveTv
  9. {
  10. public class LiveTvProgram : BaseItem, IHasLookupInfo<LiveTvProgramLookupInfo>, IHasStartDate, IHasProgramAttributes
  11. {
  12. /// <summary>
  13. /// Gets the user data key.
  14. /// </summary>
  15. /// <returns>System.String.</returns>
  16. protected override string CreateUserDataKey()
  17. {
  18. if (IsMovie)
  19. {
  20. var key = Movie.GetMovieUserDataKey(this);
  21. if (!string.IsNullOrWhiteSpace(key))
  22. {
  23. return key;
  24. }
  25. }
  26. if (IsSeries && !string.IsNullOrWhiteSpace(EpisodeTitle))
  27. {
  28. var name = GetClientTypeName();
  29. return name + "-" + Name + (EpisodeTitle ?? string.Empty);
  30. }
  31. return base.CreateUserDataKey();
  32. }
  33. [IgnoreDataMember]
  34. public override SourceType SourceType
  35. {
  36. get { return SourceType.LiveTV; }
  37. set { }
  38. }
  39. /// <summary>
  40. /// The start date of the program, in UTC.
  41. /// </summary>
  42. [IgnoreDataMember]
  43. public DateTime StartDate { get; set; }
  44. /// <summary>
  45. /// Gets or sets a value indicating whether this instance is repeat.
  46. /// </summary>
  47. /// <value><c>true</c> if this instance is repeat; otherwise, <c>false</c>.</value>
  48. [IgnoreDataMember]
  49. public bool IsRepeat { get; set; }
  50. /// <summary>
  51. /// Gets or sets the episode title.
  52. /// </summary>
  53. /// <value>The episode title.</value>
  54. [IgnoreDataMember]
  55. public string EpisodeTitle { get; set; }
  56. /// <summary>
  57. /// Gets or sets a value indicating whether this instance is movie.
  58. /// </summary>
  59. /// <value><c>true</c> if this instance is movie; otherwise, <c>false</c>.</value>
  60. [IgnoreDataMember]
  61. public bool IsMovie { get; set; }
  62. /// <summary>
  63. /// Gets or sets a value indicating whether this instance is sports.
  64. /// </summary>
  65. /// <value><c>true</c> if this instance is sports; otherwise, <c>false</c>.</value>
  66. [IgnoreDataMember]
  67. public bool IsSports { get; set; }
  68. /// <summary>
  69. /// Gets or sets a value indicating whether this instance is series.
  70. /// </summary>
  71. /// <value><c>true</c> if this instance is series; otherwise, <c>false</c>.</value>
  72. [IgnoreDataMember]
  73. public bool IsSeries { get; set; }
  74. /// <summary>
  75. /// Gets or sets a value indicating whether this instance is live.
  76. /// </summary>
  77. /// <value><c>true</c> if this instance is live; otherwise, <c>false</c>.</value>
  78. [IgnoreDataMember]
  79. public bool IsLive { get; set; }
  80. /// <summary>
  81. /// Gets or sets a value indicating whether this instance is news.
  82. /// </summary>
  83. /// <value><c>true</c> if this instance is news; otherwise, <c>false</c>.</value>
  84. [IgnoreDataMember]
  85. public bool IsNews { get; set; }
  86. /// <summary>
  87. /// Gets or sets a value indicating whether this instance is kids.
  88. /// </summary>
  89. /// <value><c>true</c> if this instance is kids; otherwise, <c>false</c>.</value>
  90. [IgnoreDataMember]
  91. public bool IsKids { get; set; }
  92. /// <summary>
  93. /// Gets or sets a value indicating whether this instance is premiere.
  94. /// </summary>
  95. /// <value><c>true</c> if this instance is premiere; otherwise, <c>false</c>.</value>
  96. [IgnoreDataMember]
  97. public bool IsPremiere { get; set; }
  98. /// <summary>
  99. /// Returns the folder containing the item.
  100. /// If the item is a folder, it returns the folder itself
  101. /// </summary>
  102. /// <value>The containing folder path.</value>
  103. [IgnoreDataMember]
  104. public override string ContainingFolderPath
  105. {
  106. get
  107. {
  108. return Path;
  109. }
  110. }
  111. /// <summary>
  112. /// Gets a value indicating whether this instance is owned item.
  113. /// </summary>
  114. /// <value><c>true</c> if this instance is owned item; otherwise, <c>false</c>.</value>
  115. [IgnoreDataMember]
  116. public override bool IsOwnedItem
  117. {
  118. get
  119. {
  120. return false;
  121. }
  122. }
  123. //[IgnoreDataMember]
  124. //public override string MediaType
  125. //{
  126. // get
  127. // {
  128. // return ChannelType == ChannelType.TV ? Model.Entities.MediaType.Video : Model.Entities.MediaType.Audio;
  129. // }
  130. //}
  131. [IgnoreDataMember]
  132. public bool IsAiring
  133. {
  134. get
  135. {
  136. var now = DateTime.UtcNow;
  137. return now >= StartDate && now < EndDate;
  138. }
  139. }
  140. [IgnoreDataMember]
  141. public bool HasAired
  142. {
  143. get
  144. {
  145. var now = DateTime.UtcNow;
  146. return now >= EndDate;
  147. }
  148. }
  149. public override string GetClientTypeName()
  150. {
  151. return "Program";
  152. }
  153. public override UnratedItem GetBlockUnratedType()
  154. {
  155. return UnratedItem.LiveTvProgram;
  156. }
  157. protected override string GetInternalMetadataPath(string basePath)
  158. {
  159. return System.IO.Path.Combine(basePath, "livetv", Id.ToString("N"));
  160. }
  161. public override bool CanDelete()
  162. {
  163. return false;
  164. }
  165. public override bool IsInternetMetadataEnabled()
  166. {
  167. if (IsMovie)
  168. {
  169. var options = (LiveTvOptions)ConfigurationManager.GetConfiguration("livetv");
  170. return options.EnableMovieProviders;
  171. }
  172. return false;
  173. }
  174. public LiveTvProgramLookupInfo GetLookupInfo()
  175. {
  176. var info = GetItemLookupInfo<LiveTvProgramLookupInfo>();
  177. info.IsMovie = IsMovie;
  178. return info;
  179. }
  180. [IgnoreDataMember]
  181. public override bool SupportsPeople
  182. {
  183. get
  184. {
  185. // Optimization
  186. if (IsNews || IsSports)
  187. {
  188. return false;
  189. }
  190. return base.SupportsPeople;
  191. }
  192. }
  193. [IgnoreDataMember]
  194. public override bool SupportsAncestors
  195. {
  196. get
  197. {
  198. return false;
  199. }
  200. }
  201. }
  202. }