DlnaService.cs 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. using System.Linq;
  2. using MediaBrowser.Controller.Dlna;
  3. using MediaBrowser.Controller.Net;
  4. using MediaBrowser.Model.Dlna;
  5. using MediaBrowser.Model.Services;
  6. namespace Emby.Dlna.Api
  7. {
  8. [Route("/Dlna/ProfileInfos", "GET", Summary = "Gets a list of profiles")]
  9. public class GetProfileInfos : IReturn<DeviceProfileInfo[]>
  10. {
  11. }
  12. [Route("/Dlna/Profiles/{Id}", "DELETE", Summary = "Deletes a profile")]
  13. public class DeleteProfile : IReturnVoid
  14. {
  15. [ApiMember(Name = "Id", Description = "Profile Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "DELETE")]
  16. public string Id { get; set; }
  17. }
  18. [Route("/Dlna/Profiles/Default", "GET", Summary = "Gets the default profile")]
  19. public class GetDefaultProfile : IReturn<DeviceProfile>
  20. {
  21. }
  22. [Route("/Dlna/Profiles/{Id}", "GET", Summary = "Gets a single profile")]
  23. public class GetProfile : IReturn<DeviceProfile>
  24. {
  25. [ApiMember(Name = "Id", Description = "Profile Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
  26. public string Id { get; set; }
  27. }
  28. [Route("/Dlna/Profiles/{Id}", "POST", Summary = "Updates a profile")]
  29. public class UpdateProfile : DeviceProfile, IReturnVoid
  30. {
  31. }
  32. [Route("/Dlna/Profiles", "POST", Summary = "Creates a profile")]
  33. public class CreateProfile : DeviceProfile, IReturnVoid
  34. {
  35. }
  36. [Authenticated(Roles = "Admin")]
  37. public class DlnaService : IService
  38. {
  39. private readonly IDlnaManager _dlnaManager;
  40. public DlnaService(IDlnaManager dlnaManager)
  41. {
  42. _dlnaManager = dlnaManager;
  43. }
  44. public object Get(GetProfileInfos request)
  45. {
  46. return _dlnaManager.GetProfileInfos().ToArray();
  47. }
  48. public object Get(GetProfile request)
  49. {
  50. return _dlnaManager.GetProfile(request.Id);
  51. }
  52. public object Get(GetDefaultProfile request)
  53. {
  54. return _dlnaManager.GetDefaultProfile();
  55. }
  56. public void Delete(DeleteProfile request)
  57. {
  58. _dlnaManager.DeleteProfile(request.Id);
  59. }
  60. public void Post(UpdateProfile request)
  61. {
  62. _dlnaManager.UpdateProfile(request);
  63. }
  64. public void Post(CreateProfile request)
  65. {
  66. _dlnaManager.CreateProfile(request);
  67. }
  68. }
  69. }