LiveTvChannel.cs 5.6 KB

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