LiveTvChannel.cs 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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. set { }
  52. }
  53. [IgnoreDataMember]
  54. public override bool EnableRememberingTrackSelections
  55. {
  56. get
  57. {
  58. return false;
  59. }
  60. }
  61. /// <summary>
  62. /// Gets or sets the number.
  63. /// </summary>
  64. /// <value>The number.</value>
  65. public string Number { get; set; }
  66. /// <summary>
  67. /// Gets or sets the type of the channel.
  68. /// </summary>
  69. /// <value>The type of the channel.</value>
  70. public ChannelType ChannelType { get; set; }
  71. [IgnoreDataMember]
  72. public override LocationType LocationType
  73. {
  74. get
  75. {
  76. // TODO: This should be removed
  77. return LocationType.Remote;
  78. }
  79. }
  80. protected override string CreateSortName()
  81. {
  82. if (!string.IsNullOrEmpty(Number))
  83. {
  84. double number = 0;
  85. if (double.TryParse(Number, NumberStyles.Any, CultureInfo.InvariantCulture, out number))
  86. {
  87. return string.Format("{0:00000.0}", number) + "-" + (Name ?? string.Empty);
  88. }
  89. }
  90. return Number + "-" + (Name ?? string.Empty);
  91. }
  92. [IgnoreDataMember]
  93. public override string MediaType
  94. {
  95. get
  96. {
  97. return ChannelType == ChannelType.Radio ? Model.Entities.MediaType.Audio : Model.Entities.MediaType.Video;
  98. }
  99. }
  100. public override string GetClientTypeName()
  101. {
  102. return "TvChannel";
  103. }
  104. public IEnumerable<BaseItem> GetTaggedItems(IEnumerable<BaseItem> inputItems)
  105. {
  106. return new List<BaseItem>();
  107. }
  108. public IEnumerable<MediaSourceInfo> GetMediaSources(bool enablePathSubstitution)
  109. {
  110. var list = new List<MediaSourceInfo>();
  111. var locationType = LocationType;
  112. var info = new MediaSourceInfo
  113. {
  114. Id = Id.ToString("N"),
  115. Protocol = locationType == LocationType.Remote ? MediaProtocol.Http : MediaProtocol.File,
  116. MediaStreams = new List<MediaStream>(),
  117. Name = Name,
  118. Path = Path,
  119. RunTimeTicks = RunTimeTicks,
  120. Type = MediaSourceType.Placeholder
  121. };
  122. list.Add(info);
  123. return list;
  124. }
  125. protected override string GetInternalMetadataPath(string basePath)
  126. {
  127. return System.IO.Path.Combine(basePath, "livetv", Id.ToString("N"), "metadata");
  128. }
  129. public override bool CanDelete()
  130. {
  131. return false;
  132. }
  133. [IgnoreDataMember]
  134. public bool IsMovie { get; set; }
  135. /// <summary>
  136. /// Gets or sets a value indicating whether this instance is sports.
  137. /// </summary>
  138. /// <value><c>true</c> if this instance is sports; otherwise, <c>false</c>.</value>
  139. [IgnoreDataMember]
  140. public bool IsSports { get; set; }
  141. /// <summary>
  142. /// Gets or sets a value indicating whether this instance is series.
  143. /// </summary>
  144. /// <value><c>true</c> if this instance is series; otherwise, <c>false</c>.</value>
  145. [IgnoreDataMember]
  146. public bool IsSeries { get; set; }
  147. /// <summary>
  148. /// Gets or sets a value indicating whether this instance is live.
  149. /// </summary>
  150. /// <value><c>true</c> if this instance is live; otherwise, <c>false</c>.</value>
  151. [IgnoreDataMember]
  152. public bool IsLive { get; set; }
  153. /// <summary>
  154. /// Gets or sets a value indicating whether this instance is news.
  155. /// </summary>
  156. /// <value><c>true</c> if this instance is news; otherwise, <c>false</c>.</value>
  157. [IgnoreDataMember]
  158. public bool IsNews { get; set; }
  159. /// <summary>
  160. /// Gets or sets a value indicating whether this instance is kids.
  161. /// </summary>
  162. /// <value><c>true</c> if this instance is kids; otherwise, <c>false</c>.</value>
  163. [IgnoreDataMember]
  164. public bool IsKids { get; set; }
  165. [IgnoreDataMember]
  166. public bool IsPremiere { get; set; }
  167. [IgnoreDataMember]
  168. public bool IsRepeat { get; set; }
  169. /// <summary>
  170. /// Gets or sets the episode title.
  171. /// </summary>
  172. /// <value>The episode title.</value>
  173. [IgnoreDataMember]
  174. public string EpisodeTitle { get; set; }
  175. }
  176. }