LiveTvChannel.cs 5.9 KB

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