LiveTvChannel.cs 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. using MediaBrowser.Controller.Entities;
  2. using MediaBrowser.Model.Configuration;
  3. using MediaBrowser.Model.Dto;
  4. using MediaBrowser.Model.Entities;
  5. using MediaBrowser.Model.LiveTv;
  6. using MediaBrowser.Model.MediaInfo;
  7. using System.Collections.Generic;
  8. using System.Globalization;
  9. using MediaBrowser.Model.Serialization;
  10. namespace MediaBrowser.Controller.LiveTv
  11. {
  12. public class LiveTvChannel : BaseItem, IHasMediaSources, IHasProgramAttributes
  13. {
  14. public override List<string> GetUserDataKeys()
  15. {
  16. var list = base.GetUserDataKeys();
  17. if (!ConfigurationManager.Configuration.DisableLiveTvChannelUserDataName)
  18. {
  19. list.Insert(0, GetClientTypeName() + "-" + Name);
  20. }
  21. return list;
  22. }
  23. public override UnratedItem GetBlockUnratedType()
  24. {
  25. return UnratedItem.LiveTvChannel;
  26. }
  27. /// <summary>
  28. /// Gets a value indicating whether this instance is owned item.
  29. /// </summary>
  30. /// <value><c>true</c> if this instance is owned item; otherwise, <c>false</c>.</value>
  31. [IgnoreDataMember]
  32. public override bool IsOwnedItem
  33. {
  34. get
  35. {
  36. return false;
  37. }
  38. }
  39. [IgnoreDataMember]
  40. public override bool SupportsPositionTicksResume
  41. {
  42. get
  43. {
  44. return false;
  45. }
  46. }
  47. [IgnoreDataMember]
  48. public override SourceType SourceType
  49. {
  50. get { return SourceType.LiveTV; }
  51. }
  52. [IgnoreDataMember]
  53. public override bool EnableRememberingTrackSelections
  54. {
  55. get
  56. {
  57. return false;
  58. }
  59. }
  60. /// <summary>
  61. /// Gets or sets the number.
  62. /// </summary>
  63. /// <value>The number.</value>
  64. public string Number { get; set; }
  65. /// <summary>
  66. /// Gets or sets the type of the channel.
  67. /// </summary>
  68. /// <value>The type of the channel.</value>
  69. public ChannelType ChannelType { get; set; }
  70. [IgnoreDataMember]
  71. public override LocationType LocationType
  72. {
  73. get
  74. {
  75. // TODO: This should be removed
  76. return LocationType.Remote;
  77. }
  78. }
  79. protected override string CreateSortName()
  80. {
  81. if (!string.IsNullOrEmpty(Number))
  82. {
  83. double number = 0;
  84. if (double.TryParse(Number, NumberStyles.Any, CultureInfo.InvariantCulture, out number))
  85. {
  86. return string.Format("{0:00000.0}", number) + "-" + (Name ?? string.Empty);
  87. }
  88. }
  89. return (Number ?? string.Empty) + "-" + (Name ?? string.Empty);
  90. }
  91. [IgnoreDataMember]
  92. public override string MediaType
  93. {
  94. get
  95. {
  96. return ChannelType == ChannelType.Radio ? Model.Entities.MediaType.Audio : Model.Entities.MediaType.Video;
  97. }
  98. }
  99. public override string GetClientTypeName()
  100. {
  101. return "TvChannel";
  102. }
  103. public IEnumerable<BaseItem> GetTaggedItems(IEnumerable<BaseItem> inputItems)
  104. {
  105. return new List<BaseItem>();
  106. }
  107. public List<MediaSourceInfo> GetMediaSources(bool enablePathSubstitution)
  108. {
  109. var list = new List<MediaSourceInfo>();
  110. var locationType = LocationType;
  111. var info = new MediaSourceInfo
  112. {
  113. Id = Id.ToString("N"),
  114. Protocol = locationType == LocationType.Remote ? MediaProtocol.Http : MediaProtocol.File,
  115. MediaStreams = new List<MediaStream>(),
  116. Name = Name,
  117. Path = Path,
  118. RunTimeTicks = RunTimeTicks,
  119. Type = MediaSourceType.Placeholder,
  120. IsInfiniteStream = RunTimeTicks == null
  121. };
  122. list.Add(info);
  123. return list;
  124. }
  125. public List<MediaStream> GetMediaStreams()
  126. {
  127. return new List<MediaStream>();
  128. }
  129. protected override string GetInternalMetadataPath(string basePath)
  130. {
  131. return System.IO.Path.Combine(basePath, "livetv", Id.ToString("N"), "metadata");
  132. }
  133. public override bool CanDelete()
  134. {
  135. return false;
  136. }
  137. [IgnoreDataMember]
  138. public bool IsMovie { get; set; }
  139. /// <summary>
  140. /// Gets or sets a value indicating whether this instance is sports.
  141. /// </summary>
  142. /// <value><c>true</c> if this instance is sports; otherwise, <c>false</c>.</value>
  143. [IgnoreDataMember]
  144. public bool IsSports { get; set; }
  145. /// <summary>
  146. /// Gets or sets a value indicating whether this instance is series.
  147. /// </summary>
  148. /// <value><c>true</c> if this instance is series; otherwise, <c>false</c>.</value>
  149. [IgnoreDataMember]
  150. public bool IsSeries { get; set; }
  151. /// <summary>
  152. /// Gets or sets a value indicating whether this instance is live.
  153. /// </summary>
  154. /// <value><c>true</c> if this instance is live; otherwise, <c>false</c>.</value>
  155. [IgnoreDataMember]
  156. public bool IsLive { get; set; }
  157. /// <summary>
  158. /// Gets or sets a value indicating whether this instance is news.
  159. /// </summary>
  160. /// <value><c>true</c> if this instance is news; otherwise, <c>false</c>.</value>
  161. [IgnoreDataMember]
  162. public bool IsNews { get; set; }
  163. /// <summary>
  164. /// Gets or sets a value indicating whether this instance is kids.
  165. /// </summary>
  166. /// <value><c>true</c> if this instance is kids; otherwise, <c>false</c>.</value>
  167. [IgnoreDataMember]
  168. public bool IsKids { get; set; }
  169. [IgnoreDataMember]
  170. public bool IsPremiere { get; set; }
  171. [IgnoreDataMember]
  172. public bool IsRepeat { get; set; }
  173. /// <summary>
  174. /// Gets or sets the episode title.
  175. /// </summary>
  176. /// <value>The episode title.</value>
  177. [IgnoreDataMember]
  178. public string EpisodeTitle { get; set; }
  179. }
  180. }