LiveTvChannel.cs 5.1 KB

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