LiveTvVideoRecording.cs 4.3 KB

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