LiveTvChannel.cs 5.7 KB

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