LiveTvProgram.cs 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. using MediaBrowser.Controller.Entities;
  2. using MediaBrowser.Controller.Library;
  3. using MediaBrowser.Model.LiveTv;
  4. using System;
  5. using System.Threading;
  6. using System.Threading.Tasks;
  7. namespace MediaBrowser.Controller.LiveTv
  8. {
  9. public class LiveTvProgram : BaseItem
  10. {
  11. /// <summary>
  12. /// Gets the user data key.
  13. /// </summary>
  14. /// <returns>System.String.</returns>
  15. public override string GetUserDataKey()
  16. {
  17. return GetClientTypeName() + "-" + Name;
  18. }
  19. /// <summary>
  20. /// Id of the program.
  21. /// </summary>
  22. public string ExternalId { get; set; }
  23. /// <summary>
  24. /// Gets or sets the channel identifier.
  25. /// </summary>
  26. /// <value>The channel identifier.</value>
  27. public string ExternalChannelId { get; set; }
  28. /// <summary>
  29. /// Gets or sets the type of the channel.
  30. /// </summary>
  31. /// <value>The type of the channel.</value>
  32. public ChannelType ChannelType { get; set; }
  33. /// <summary>
  34. /// The start date of the program, in UTC.
  35. /// </summary>
  36. public DateTime StartDate { get; set; }
  37. /// <summary>
  38. /// Gets or sets a value indicating whether this instance is hd.
  39. /// </summary>
  40. /// <value><c>true</c> if this instance is hd; otherwise, <c>false</c>.</value>
  41. public bool? IsHD { get; set; }
  42. /// <summary>
  43. /// Gets or sets the audio.
  44. /// </summary>
  45. /// <value>The audio.</value>
  46. public ProgramAudio? Audio { get; set; }
  47. /// <summary>
  48. /// Gets or sets a value indicating whether this instance is repeat.
  49. /// </summary>
  50. /// <value><c>true</c> if this instance is repeat; otherwise, <c>false</c>.</value>
  51. public bool IsRepeat { get; set; }
  52. /// <summary>
  53. /// Gets or sets the episode title.
  54. /// </summary>
  55. /// <value>The episode title.</value>
  56. public string EpisodeTitle { get; set; }
  57. /// <summary>
  58. /// Gets or sets the name of the service.
  59. /// </summary>
  60. /// <value>The name of the service.</value>
  61. public string ServiceName { get; set; }
  62. /// <summary>
  63. /// Supply the image path if it can be accessed directly from the file system
  64. /// </summary>
  65. /// <value>The image path.</value>
  66. public string ProviderImagePath { get; set; }
  67. /// <summary>
  68. /// Supply the image url if it can be downloaded
  69. /// </summary>
  70. /// <value>The image URL.</value>
  71. public string ProviderImageUrl { get; set; }
  72. /// <summary>
  73. /// Gets or sets a value indicating whether this instance has image.
  74. /// </summary>
  75. /// <value><c>null</c> if [has image] contains no value, <c>true</c> if [has image]; otherwise, <c>false</c>.</value>
  76. public bool? HasProviderImage { get; set; }
  77. /// <summary>
  78. /// Gets or sets a value indicating whether this instance is movie.
  79. /// </summary>
  80. /// <value><c>true</c> if this instance is movie; otherwise, <c>false</c>.</value>
  81. public bool IsMovie { get; set; }
  82. /// <summary>
  83. /// Gets or sets a value indicating whether this instance is sports.
  84. /// </summary>
  85. /// <value><c>true</c> if this instance is sports; otherwise, <c>false</c>.</value>
  86. public bool IsSports { get; set; }
  87. /// <summary>
  88. /// Gets or sets a value indicating whether this instance is series.
  89. /// </summary>
  90. /// <value><c>true</c> if this instance is series; otherwise, <c>false</c>.</value>
  91. public bool IsSeries { get; set; }
  92. /// <summary>
  93. /// Gets or sets a value indicating whether this instance is live.
  94. /// </summary>
  95. /// <value><c>true</c> if this instance is live; otherwise, <c>false</c>.</value>
  96. public bool IsLive { get; set; }
  97. /// <summary>
  98. /// Gets or sets a value indicating whether this instance is news.
  99. /// </summary>
  100. /// <value><c>true</c> if this instance is news; otherwise, <c>false</c>.</value>
  101. public bool IsNews { get; set; }
  102. /// <summary>
  103. /// Gets or sets a value indicating whether this instance is kids.
  104. /// </summary>
  105. /// <value><c>true</c> if this instance is kids; otherwise, <c>false</c>.</value>
  106. public bool IsKids { get; set; }
  107. /// <summary>
  108. /// Gets or sets a value indicating whether this instance is premiere.
  109. /// </summary>
  110. /// <value><c>true</c> if this instance is premiere; otherwise, <c>false</c>.</value>
  111. public bool IsPremiere { get; set; }
  112. /// <summary>
  113. /// Returns the folder containing the item.
  114. /// If the item is a folder, it returns the folder itself
  115. /// </summary>
  116. /// <value>The containing folder path.</value>
  117. public override string ContainingFolderPath
  118. {
  119. get
  120. {
  121. return Path;
  122. }
  123. }
  124. /// <summary>
  125. /// Gets a value indicating whether this instance is owned item.
  126. /// </summary>
  127. /// <value><c>true</c> if this instance is owned item; otherwise, <c>false</c>.</value>
  128. public override bool IsOwnedItem
  129. {
  130. get
  131. {
  132. return false;
  133. }
  134. }
  135. public override string MediaType
  136. {
  137. get
  138. {
  139. return ChannelType == ChannelType.TV ? Model.Entities.MediaType.Video : Model.Entities.MediaType.Audio;
  140. }
  141. }
  142. public bool IsAiring
  143. {
  144. get
  145. {
  146. var now = DateTime.UtcNow;
  147. return now >= StartDate && now < EndDate;
  148. }
  149. }
  150. public bool HasAired
  151. {
  152. get
  153. {
  154. var now = DateTime.UtcNow;
  155. return now >= EndDate;
  156. }
  157. }
  158. public override string GetClientTypeName()
  159. {
  160. return "Program";
  161. }
  162. public override Task UpdateToRepository(ItemUpdateType updateReason, CancellationToken cancellationToken)
  163. {
  164. DateLastSaved = DateTime.UtcNow;
  165. // Avoid library manager and keep out of in-memory cache
  166. // Not great that this class has to know about that, but we'll improve that later.
  167. return ItemRepository.SaveItem(this, cancellationToken);
  168. }
  169. }
  170. }