LiveTvVideoRecording.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. using MediaBrowser.Controller.Entities;
  2. using MediaBrowser.Model.Configuration;
  3. using MediaBrowser.Model.Dto;
  4. using MediaBrowser.Model.Entities;
  5. using MediaBrowser.Model.Users;
  6. using System.Collections.Generic;
  7. using System.Linq;
  8. using System.Runtime.Serialization;
  9. namespace MediaBrowser.Controller.LiveTv
  10. {
  11. public class LiveTvVideoRecording : Video, ILiveTvRecording
  12. {
  13. /// <summary>
  14. /// Gets the user data key.
  15. /// </summary>
  16. /// <returns>System.String.</returns>
  17. protected override string CreateUserDataKey()
  18. {
  19. var name = GetClientTypeName();
  20. if (!string.IsNullOrEmpty(RecordingInfo.ProgramId))
  21. {
  22. return name + "-" + RecordingInfo.ProgramId;
  23. }
  24. return name + "-" + RecordingInfo.Name + (RecordingInfo.EpisodeTitle ?? string.Empty);
  25. }
  26. public RecordingInfo RecordingInfo { get; set; }
  27. public string ServiceName { get; set; }
  28. [IgnoreDataMember]
  29. public override string MediaType
  30. {
  31. get
  32. {
  33. return Model.Entities.MediaType.Video;
  34. }
  35. }
  36. [IgnoreDataMember]
  37. public override LocationType LocationType
  38. {
  39. get
  40. {
  41. if (!string.IsNullOrEmpty(Path))
  42. {
  43. return base.LocationType;
  44. }
  45. return LocationType.Remote;
  46. }
  47. }
  48. /// <summary>
  49. /// Gets a value indicating whether this instance is owned item.
  50. /// </summary>
  51. /// <value><c>true</c> if this instance is owned item; otherwise, <c>false</c>.</value>
  52. [IgnoreDataMember]
  53. public override bool IsOwnedItem
  54. {
  55. get
  56. {
  57. return false;
  58. }
  59. }
  60. public override string GetClientTypeName()
  61. {
  62. return "Recording";
  63. }
  64. public override bool IsSaveLocalMetadataEnabled()
  65. {
  66. return false;
  67. }
  68. public override bool SupportsLocalMetadata
  69. {
  70. get
  71. {
  72. return false;
  73. }
  74. }
  75. protected override bool GetBlockUnratedValue(UserPolicy config)
  76. {
  77. return config.BlockUnratedItems.Contains(UnratedItem.LiveTvProgram);
  78. }
  79. protected override string GetInternalMetadataPath(string basePath)
  80. {
  81. return System.IO.Path.Combine(basePath, "livetv", Id.ToString("N"));
  82. }
  83. public override bool IsAuthorizedToDelete(User user)
  84. {
  85. return user.Policy.EnableLiveTvManagement;
  86. }
  87. public override IEnumerable<MediaSourceInfo> GetMediaSources(bool enablePathSubstitution)
  88. {
  89. var list = base.GetMediaSources(enablePathSubstitution).ToList();
  90. foreach (var mediaSource in list)
  91. {
  92. if (string.IsNullOrWhiteSpace(mediaSource.Path))
  93. {
  94. mediaSource.Type = MediaSourceType.Placeholder;
  95. }
  96. }
  97. return list;
  98. }
  99. }
  100. }