LiveTvChannel.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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.Linq;
  9. namespace MediaBrowser.Controller.LiveTv
  10. {
  11. public class LiveTvChannel : BaseItem, IHasMediaSources
  12. {
  13. /// <summary>
  14. /// Gets the user data key.
  15. /// </summary>
  16. /// <returns>System.String.</returns>
  17. public override string GetUserDataKey()
  18. {
  19. return GetClientTypeName() + "-" + Name;
  20. }
  21. /// <summary>
  22. /// Returns the folder containing the item.
  23. /// If the item is a folder, it returns the folder itself
  24. /// </summary>
  25. /// <value>The containing folder path.</value>
  26. public override string ContainingFolderPath
  27. {
  28. get
  29. {
  30. return Path;
  31. }
  32. }
  33. protected override bool GetBlockUnratedValue(UserConfiguration config)
  34. {
  35. return config.BlockUnratedItems.Contains(UnratedItem.LiveTvChannel);
  36. }
  37. /// <summary>
  38. /// Gets a value indicating whether this instance is owned item.
  39. /// </summary>
  40. /// <value><c>true</c> if this instance is owned item; otherwise, <c>false</c>.</value>
  41. public override bool IsOwnedItem
  42. {
  43. get
  44. {
  45. return false;
  46. }
  47. }
  48. /// <summary>
  49. /// Gets or sets the number.
  50. /// </summary>
  51. /// <value>The number.</value>
  52. public string Number { get; set; }
  53. /// <summary>
  54. /// Gets or sets the external identifier.
  55. /// </summary>
  56. /// <value>The external identifier.</value>
  57. public string ExternalId { get; set; }
  58. /// <summary>
  59. /// Gets or sets the type of the channel.
  60. /// </summary>
  61. /// <value>The type of the channel.</value>
  62. public ChannelType ChannelType { get; set; }
  63. public string ServiceName { get; set; }
  64. /// <summary>
  65. /// Supply the image path if it can be accessed directly from the file system
  66. /// </summary>
  67. /// <value>The image path.</value>
  68. public string ProviderImagePath { get; set; }
  69. /// <summary>
  70. /// Supply the image url if it can be downloaded
  71. /// </summary>
  72. /// <value>The image URL.</value>
  73. public string ProviderImageUrl { get; set; }
  74. /// <summary>
  75. /// Gets or sets a value indicating whether this instance has image.
  76. /// </summary>
  77. /// <value><c>null</c> if [has image] contains no value, <c>true</c> if [has image]; otherwise, <c>false</c>.</value>
  78. public bool? HasProviderImage { get; set; }
  79. protected override string CreateSortName()
  80. {
  81. double number = 0;
  82. if (!string.IsNullOrEmpty(Number))
  83. {
  84. double.TryParse(Number, out number);
  85. }
  86. return number.ToString("000-") + (Name ?? string.Empty);
  87. }
  88. public override string MediaType
  89. {
  90. get
  91. {
  92. return ChannelType == ChannelType.Radio ? Model.Entities.MediaType.Audio : Model.Entities.MediaType.Video;
  93. }
  94. }
  95. public override string GetClientTypeName()
  96. {
  97. return "TvChannel";
  98. }
  99. public IEnumerable<BaseItem> GetTaggedItems(IEnumerable<BaseItem> inputItems)
  100. {
  101. return new List<BaseItem>();
  102. }
  103. public IEnumerable<MediaSourceInfo> GetMediaSources(bool enablePathSubstitution)
  104. {
  105. var list = new List<MediaSourceInfo>();
  106. var locationType = LocationType;
  107. var info = new MediaSourceInfo
  108. {
  109. Id = Id.ToString("N"),
  110. Protocol = locationType == LocationType.Remote ? MediaProtocol.Http : MediaProtocol.File,
  111. MediaStreams = new List<MediaStream>(),
  112. Name = Name,
  113. Path = Path,
  114. RunTimeTicks = RunTimeTicks,
  115. Type = MediaSourceType.Default
  116. };
  117. list.Add(info);
  118. return list;
  119. }
  120. }
  121. }