LiveTvVideoRecording.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. using MediaBrowser.Controller.Entities;
  2. using MediaBrowser.Controller.Entities.Movies;
  3. using MediaBrowser.Model.Configuration;
  4. using MediaBrowser.Model.Dto;
  5. using MediaBrowser.Model.Entities;
  6. using MediaBrowser.Model.LiveTv;
  7. using MediaBrowser.Model.Users;
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Linq;
  11. using System.Runtime.Serialization;
  12. namespace MediaBrowser.Controller.LiveTv
  13. {
  14. public class LiveTvVideoRecording : Video, ILiveTvRecording
  15. {
  16. public string ExternalId { get; set; }
  17. public string ProviderImagePath { get; set; }
  18. public string ProviderImageUrl { get; set; }
  19. public string EpisodeTitle { get; set; }
  20. public bool IsSeries { get; set; }
  21. public string SeriesTimerId { get; set; }
  22. [IgnoreDataMember]
  23. public DateTime StartDate { get; set; }
  24. public RecordingStatus Status { get; set; }
  25. [IgnoreDataMember]
  26. public bool IsSports { get; set; }
  27. public bool IsNews { get; set; }
  28. [IgnoreDataMember]
  29. public bool IsKids { get; set; }
  30. public bool IsRepeat { get; set; }
  31. [IgnoreDataMember]
  32. public bool IsMovie { get; set; }
  33. public bool? IsHD { get; set; }
  34. public bool IsLive { get; set; }
  35. public bool IsPremiere { get; set; }
  36. public ChannelType ChannelType { get; set; }
  37. public string ProgramId { get; set; }
  38. public ProgramAudio? Audio { get; set; }
  39. public DateTime? OriginalAirDate { get; set; }
  40. /// <summary>
  41. /// Gets the user data key.
  42. /// </summary>
  43. /// <returns>System.String.</returns>
  44. protected override string CreateUserDataKey()
  45. {
  46. if (IsMovie)
  47. {
  48. var key = Movie.GetMovieUserDataKey(this);
  49. if (!string.IsNullOrWhiteSpace(key))
  50. {
  51. return key;
  52. }
  53. }
  54. var name = GetClientTypeName();
  55. if (!string.IsNullOrEmpty(ProgramId))
  56. {
  57. return name + "-" + ProgramId;
  58. }
  59. return name + "-" + Name + (EpisodeTitle ?? string.Empty);
  60. }
  61. public string ServiceName { get; set; }
  62. [IgnoreDataMember]
  63. public override string MediaType
  64. {
  65. get
  66. {
  67. return Model.Entities.MediaType.Video;
  68. }
  69. }
  70. [IgnoreDataMember]
  71. public override LocationType LocationType
  72. {
  73. get
  74. {
  75. if (!string.IsNullOrEmpty(Path))
  76. {
  77. return base.LocationType;
  78. }
  79. return LocationType.Remote;
  80. }
  81. }
  82. /// <summary>
  83. /// Gets a value indicating whether this instance is owned item.
  84. /// </summary>
  85. /// <value><c>true</c> if this instance is owned item; otherwise, <c>false</c>.</value>
  86. [IgnoreDataMember]
  87. public override bool IsOwnedItem
  88. {
  89. get
  90. {
  91. return false;
  92. }
  93. }
  94. public override string GetClientTypeName()
  95. {
  96. return "Recording";
  97. }
  98. public override bool IsSaveLocalMetadataEnabled()
  99. {
  100. return false;
  101. }
  102. public override bool SupportsLocalMetadata
  103. {
  104. get
  105. {
  106. return false;
  107. }
  108. }
  109. protected override bool GetBlockUnratedValue(UserPolicy config)
  110. {
  111. return config.BlockUnratedItems.Contains(UnratedItem.LiveTvProgram);
  112. }
  113. protected override string GetInternalMetadataPath(string basePath)
  114. {
  115. return System.IO.Path.Combine(basePath, "livetv", Id.ToString("N"));
  116. }
  117. public override bool CanDelete()
  118. {
  119. return true;
  120. }
  121. public override bool IsAuthorizedToDelete(User user)
  122. {
  123. return user.Policy.EnableLiveTvManagement;
  124. }
  125. public override IEnumerable<MediaSourceInfo> GetMediaSources(bool enablePathSubstitution)
  126. {
  127. var list = base.GetMediaSources(enablePathSubstitution).ToList();
  128. foreach (var mediaSource in list)
  129. {
  130. if (string.IsNullOrWhiteSpace(mediaSource.Path))
  131. {
  132. mediaSource.Type = MediaSourceType.Placeholder;
  133. }
  134. }
  135. return list;
  136. }
  137. }
  138. }