LiveTvChannel.cs 5.6 KB

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