LiveTvAudioRecording.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. using System.Runtime.Serialization;
  2. using MediaBrowser.Controller.Entities;
  3. using MediaBrowser.Controller.Entities.Audio;
  4. using MediaBrowser.Model.Configuration;
  5. using MediaBrowser.Model.Entities;
  6. using MediaBrowser.Model.Users;
  7. using System.Linq;
  8. namespace MediaBrowser.Controller.LiveTv
  9. {
  10. public class LiveTvAudioRecording : Audio, ILiveTvRecording
  11. {
  12. /// <summary>
  13. /// Gets the user data key.
  14. /// </summary>
  15. /// <returns>System.String.</returns>
  16. protected override string CreateUserDataKey()
  17. {
  18. var name = GetClientTypeName();
  19. if (!string.IsNullOrEmpty(RecordingInfo.ProgramId))
  20. {
  21. return name + "-" + RecordingInfo.ProgramId;
  22. }
  23. return name + "-" + RecordingInfo.Name + (RecordingInfo.EpisodeTitle ?? string.Empty);
  24. }
  25. public RecordingInfo RecordingInfo { get; set; }
  26. public string ServiceName { get; set; }
  27. /// <summary>
  28. /// Gets a value indicating whether this instance is owned item.
  29. /// </summary>
  30. /// <value><c>true</c> if this instance is owned item; otherwise, <c>false</c>.</value>
  31. [IgnoreDataMember]
  32. public override bool IsOwnedItem
  33. {
  34. get
  35. {
  36. return false;
  37. }
  38. }
  39. [IgnoreDataMember]
  40. public override string MediaType
  41. {
  42. get
  43. {
  44. return Model.Entities.MediaType.Audio;
  45. }
  46. }
  47. [IgnoreDataMember]
  48. public override LocationType LocationType
  49. {
  50. get
  51. {
  52. if (!string.IsNullOrEmpty(Path))
  53. {
  54. return base.LocationType;
  55. }
  56. return LocationType.Remote;
  57. }
  58. }
  59. public override string GetClientTypeName()
  60. {
  61. return "Recording";
  62. }
  63. public override bool IsSaveLocalMetadataEnabled()
  64. {
  65. return false;
  66. }
  67. [IgnoreDataMember]
  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. }
  88. }