LiveTvAudioRecording.cs 3.2 KB

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