2013-08-04 20:26:37 +03:00
|
|
|
using System.Collections.Generic;
|
2013-08-03 06:01:16 +03:00
|
|
|
using System.Linq;
|
2013-02-06 09:28:56 +03:00
|
|
|
using Nancy;
|
2013-02-23 23:35:26 +03:00
|
|
|
using NzbDrone.Api.Extensions;
|
2013-02-06 09:28:56 +03:00
|
|
|
using NzbDrone.Common;
|
|
|
|
|
|
|
|
namespace NzbDrone.Api.Directories
|
|
|
|
{
|
|
|
|
public class DirectoryModule : NzbDroneApiModule
|
|
|
|
{
|
2013-08-03 06:01:16 +03:00
|
|
|
private readonly IDirectoryLookupService _directoryLookupService;
|
2013-02-06 09:28:56 +03:00
|
|
|
|
2013-08-03 06:01:16 +03:00
|
|
|
public DirectoryModule(IDirectoryLookupService directoryLookupService)
|
2013-02-06 09:28:56 +03:00
|
|
|
: base("/directories")
|
|
|
|
{
|
2013-08-03 06:01:16 +03:00
|
|
|
_directoryLookupService = directoryLookupService;
|
2013-02-16 02:38:53 +03:00
|
|
|
Get["/"] = x => GetDirectories();
|
2013-02-06 09:28:56 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
private Response GetDirectories()
|
|
|
|
{
|
2013-02-16 02:38:53 +03:00
|
|
|
if (!Request.Query.query.HasValue)
|
2013-02-06 09:28:56 +03:00
|
|
|
return new List<string>().AsResponse();
|
|
|
|
|
2013-02-16 02:38:53 +03:00
|
|
|
string query = Request.Query.query.Value;
|
2013-02-06 09:28:56 +03:00
|
|
|
|
2013-08-04 20:26:37 +03:00
|
|
|
var dirs = _directoryLookupService.LookupSubDirectories(query)
|
|
|
|
.Select(p => p.GetActualCasing())
|
|
|
|
.ToList();
|
2013-02-06 09:28:56 +03:00
|
|
|
|
|
|
|
return dirs.AsResponse();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|