LibraryService.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. using MediaBrowser.Common;
  2. using MediaBrowser.Controller.Library;
  3. using ServiceStack;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. namespace MediaBrowser.Api.Library
  8. {
  9. /// <summary>
  10. /// Class GetPhyscialPaths
  11. /// </summary>
  12. [Route("/Library/PhysicalPaths", "GET")]
  13. [Api(Description = "Gets a list of physical paths from virtual folders")]
  14. public class GetPhyscialPaths : IReturn<List<string>>
  15. {
  16. }
  17. /// <summary>
  18. /// Class LibraryService
  19. /// </summary>
  20. public class LibraryService : BaseApiService
  21. {
  22. /// <summary>
  23. /// The _app host
  24. /// </summary>
  25. private readonly IApplicationHost _appHost;
  26. private readonly ILibraryManager _libraryManager;
  27. /// <summary>
  28. /// Initializes a new instance of the <see cref="LibraryService" /> class.
  29. /// </summary>
  30. /// <param name="appHost">The app host.</param>
  31. /// <param name="libraryManager">The library manager.</param>
  32. /// <exception cref="System.ArgumentNullException">appHost</exception>
  33. public LibraryService(IApplicationHost appHost, ILibraryManager libraryManager)
  34. {
  35. if (appHost == null)
  36. {
  37. throw new ArgumentNullException("appHost");
  38. }
  39. _appHost = appHost;
  40. _libraryManager = libraryManager;
  41. }
  42. /// <summary>
  43. /// Gets the specified request.
  44. /// </summary>
  45. /// <param name="request">The request.</param>
  46. /// <returns>System.Object.</returns>
  47. public object Get(GetPhyscialPaths request)
  48. {
  49. var result = _libraryManager.RootFolder.Children
  50. .SelectMany(c => c.PhysicalLocations)
  51. .ToList();
  52. return ToOptimizedSerializedResultUsingCache(result);
  53. }
  54. }
  55. }