LiveTvVideoRecording.cs 4.0 KB

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