2013-03-04 05:43:06 +00:00
|
|
|
|
using MediaBrowser.Common;
|
2013-02-21 01:33:05 +00:00
|
|
|
|
using MediaBrowser.Controller.Library;
|
2013-12-07 15:52:38 +00:00
|
|
|
|
using ServiceStack;
|
2013-02-21 01:33:05 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
2013-02-25 03:56:00 +00:00
|
|
|
|
namespace MediaBrowser.Api.Library
|
2013-02-21 01:33:05 +00:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Class GetPhyscialPaths
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Route("/Library/PhysicalPaths", "GET")]
|
2013-03-24 02:45:00 +00:00
|
|
|
|
[Api(Description = "Gets a list of physical paths from virtual folders")]
|
2013-02-21 01:33:05 +00:00
|
|
|
|
public class GetPhyscialPaths : IReturn<List<string>>
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Class LibraryService
|
|
|
|
|
/// </summary>
|
2013-03-16 05:52:33 +00:00
|
|
|
|
public class LibraryService : BaseApiService
|
2013-02-21 01:33:05 +00:00
|
|
|
|
{
|
2013-02-24 21:53:54 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// The _app host
|
|
|
|
|
/// </summary>
|
|
|
|
|
private readonly IApplicationHost _appHost;
|
2013-02-28 19:32:41 +00:00
|
|
|
|
private readonly ILibraryManager _libraryManager;
|
2013-02-24 21:53:54 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Initializes a new instance of the <see cref="LibraryService" /> class.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="appHost">The app host.</param>
|
2013-04-02 17:37:49 +00:00
|
|
|
|
/// <param name="libraryManager">The library manager.</param>
|
2013-02-24 21:53:54 +00:00
|
|
|
|
/// <exception cref="System.ArgumentNullException">appHost</exception>
|
2013-04-22 04:38:03 +00:00
|
|
|
|
public LibraryService(IApplicationHost appHost, ILibraryManager libraryManager)
|
2013-02-24 21:53:54 +00:00
|
|
|
|
{
|
|
|
|
|
if (appHost == null)
|
|
|
|
|
{
|
|
|
|
|
throw new ArgumentNullException("appHost");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_appHost = appHost;
|
2013-02-28 19:32:41 +00:00
|
|
|
|
_libraryManager = libraryManager;
|
2013-02-21 01:33:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the specified request.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="request">The request.</param>
|
|
|
|
|
/// <returns>System.Object.</returns>
|
|
|
|
|
public object Get(GetPhyscialPaths request)
|
|
|
|
|
{
|
2013-12-20 16:51:25 +00:00
|
|
|
|
var result = _libraryManager.RootFolder.Children
|
2014-02-10 20:11:46 +00:00
|
|
|
|
.SelectMany(c => c.PhysicalLocations)
|
2013-12-20 16:51:25 +00:00
|
|
|
|
.ToList();
|
2013-02-21 01:33:05 +00:00
|
|
|
|
|
2014-02-04 04:04:19 +00:00
|
|
|
|
return ToOptimizedSerializedResultUsingCache(result);
|
2013-02-21 01:33:05 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|