LiveTvChannel.cs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. #nullable disable
  2. #pragma warning disable CS1591
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Globalization;
  6. using System.Linq;
  7. using System.Text.Json.Serialization;
  8. using Jellyfin.Data.Enums;
  9. using MediaBrowser.Controller.Entities;
  10. using MediaBrowser.Model.Dto;
  11. using MediaBrowser.Model.Entities;
  12. using MediaBrowser.Model.LiveTv;
  13. using MediaBrowser.Model.MediaInfo;
  14. namespace MediaBrowser.Controller.LiveTv
  15. {
  16. public class LiveTvChannel : BaseItem, IHasMediaSources, IHasProgramAttributes
  17. {
  18. public override List<string> GetUserDataKeys()
  19. {
  20. var list = base.GetUserDataKeys();
  21. if (!ConfigurationManager.Configuration.DisableLiveTvChannelUserDataName)
  22. {
  23. list.Insert(0, GetClientTypeName() + "-" + Name);
  24. }
  25. return list;
  26. }
  27. public override UnratedItem GetBlockUnratedType()
  28. {
  29. return UnratedItem.LiveTvChannel;
  30. }
  31. [JsonIgnore]
  32. public override bool SupportsPositionTicksResume => false;
  33. [JsonIgnore]
  34. public override SourceType SourceType => SourceType.LiveTV;
  35. [JsonIgnore]
  36. public override bool EnableRememberingTrackSelections => false;
  37. /// <summary>
  38. /// Gets or sets the number.
  39. /// </summary>
  40. /// <value>The number.</value>
  41. public string Number { get; set; }
  42. /// <summary>
  43. /// Gets or sets the type of the channel.
  44. /// </summary>
  45. /// <value>The type of the channel.</value>
  46. public ChannelType ChannelType { get; set; }
  47. [JsonIgnore]
  48. public override LocationType LocationType => LocationType.Remote;
  49. protected override string CreateSortName()
  50. {
  51. if (!string.IsNullOrEmpty(Number))
  52. {
  53. double number = 0;
  54. if (double.TryParse(Number, NumberStyles.Any, CultureInfo.InvariantCulture, out number))
  55. {
  56. return string.Format(CultureInfo.InvariantCulture, "{0:00000.0}", number) + "-" + (Name ?? string.Empty);
  57. }
  58. }
  59. return (Number ?? string.Empty) + "-" + (Name ?? string.Empty);
  60. }
  61. [JsonIgnore]
  62. public override string MediaType => ChannelType == ChannelType.Radio ? Model.Entities.MediaType.Audio : Model.Entities.MediaType.Video;
  63. public override string GetClientTypeName()
  64. {
  65. return "TvChannel";
  66. }
  67. public IEnumerable<BaseItem> GetTaggedItems(IEnumerable<BaseItem> inputItems)
  68. {
  69. return new List<BaseItem>();
  70. }
  71. public override List<MediaSourceInfo> GetMediaSources(bool enablePathSubstitution)
  72. {
  73. var list = new List<MediaSourceInfo>();
  74. var info = new MediaSourceInfo
  75. {
  76. Id = Id.ToString("N", CultureInfo.InvariantCulture),
  77. Protocol = PathProtocol ?? MediaProtocol.File,
  78. MediaStreams = new List<MediaStream>(),
  79. Name = Name,
  80. Path = Path,
  81. RunTimeTicks = RunTimeTicks,
  82. Type = MediaSourceType.Placeholder,
  83. IsInfiniteStream = RunTimeTicks == null
  84. };
  85. list.Add(info);
  86. return list;
  87. }
  88. public override List<MediaStream> GetMediaStreams()
  89. {
  90. return new List<MediaStream>();
  91. }
  92. protected override string GetInternalMetadataPath(string basePath)
  93. {
  94. return System.IO.Path.Combine(basePath, "livetv", Id.ToString("N", CultureInfo.InvariantCulture), "metadata");
  95. }
  96. public override bool CanDelete()
  97. {
  98. return false;
  99. }
  100. [JsonIgnore]
  101. public bool IsMovie { get; set; }
  102. /// <summary>
  103. /// Gets or sets a value indicating whether this instance is sports.
  104. /// </summary>
  105. /// <value><c>true</c> if this instance is sports; otherwise, <c>false</c>.</value>
  106. [JsonIgnore]
  107. public bool IsSports { get; set; }
  108. /// <summary>
  109. /// Gets or sets a value indicating whether this instance is series.
  110. /// </summary>
  111. /// <value><c>true</c> if this instance is series; otherwise, <c>false</c>.</value>
  112. [JsonIgnore]
  113. public bool IsSeries { get; set; }
  114. /// <summary>
  115. /// Gets or sets a value indicating whether this instance is news.
  116. /// </summary>
  117. /// <value><c>true</c> if this instance is news; otherwise, <c>false</c>.</value>
  118. [JsonIgnore]
  119. public bool IsNews { get; set; }
  120. /// <summary>
  121. /// Gets a value indicating whether this instance is kids.
  122. /// </summary>
  123. /// <value><c>true</c> if this instance is kids; otherwise, <c>false</c>.</value>
  124. [JsonIgnore]
  125. public bool IsKids => Tags.Contains("Kids", StringComparer.OrdinalIgnoreCase);
  126. [JsonIgnore]
  127. public bool IsRepeat { get; set; }
  128. /// <summary>
  129. /// Gets or sets the episode title.
  130. /// </summary>
  131. /// <value>The episode title.</value>
  132. [JsonIgnore]
  133. public string EpisodeTitle { get; set; }
  134. }
  135. }