Add state filter to info endpoint and also implement the count endpoint
This commit is contained in:
parent
5054ca4ae1
commit
d4e1502c60
1 changed files with 36 additions and 1 deletions
|
|
@ -159,6 +159,11 @@ public class QBittorrentController(ILogger<QBittorrentController> logger, QBitto
|
||||||
{
|
{
|
||||||
var results = await qBittorrent.TorrentInfo();
|
var results = await qBittorrent.TorrentInfo();
|
||||||
|
|
||||||
|
if(!String.IsNullOrWhiteSpace(request.Filter))
|
||||||
|
{
|
||||||
|
results = results.Where(m => m.State != null && m.State.Equals(request.Filter, StringComparison.OrdinalIgnoreCase)).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
if (!String.IsNullOrWhiteSpace(request.Category))
|
if (!String.IsNullOrWhiteSpace(request.Category))
|
||||||
{
|
{
|
||||||
results = results.Where(m => m.Category == request.Category).ToList();
|
results = results.Where(m => m.Category == request.Category).ToList();
|
||||||
|
|
@ -178,11 +183,34 @@ public class QBittorrentController(ILogger<QBittorrentController> logger, QBitto
|
||||||
[Authorize(Policy = "AuthSetting")]
|
[Authorize(Policy = "AuthSetting")]
|
||||||
[Route("torrents/info")]
|
[Route("torrents/info")]
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task<ActionResult<IList<TorrentInfo>>> TorrentsFilesPost([FromForm] QBTorrentsInfoRequest request)
|
public async Task<ActionResult<IList<TorrentInfo>>> TorrentsInfoPost([FromForm] QBTorrentsInfoRequest request)
|
||||||
{
|
{
|
||||||
return await TorrentsInfo(request);
|
return await TorrentsInfo(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Authorize(Policy = "AuthSetting")]
|
||||||
|
[Route("torrents/count")]
|
||||||
|
[HttpGet]
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<ActionResult<int>> TorrentsCount([FromQuery] QBTorrentsCountRequest request)
|
||||||
|
{
|
||||||
|
var results = await qBittorrent.TorrentInfo();
|
||||||
|
|
||||||
|
if (!String.IsNullOrWhiteSpace(request.Filter))
|
||||||
|
{
|
||||||
|
results = results.Where(m => m.State != null && m.State.Equals(request.Filter, StringComparison.OrdinalIgnoreCase)).ToList();
|
||||||
|
}
|
||||||
|
return results.Count;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Authorize(Policy = "AuthSetting")]
|
||||||
|
[Route("torrents/count")]
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<ActionResult<int>> TorrentsCountPost([FromForm] QBTorrentsCountRequest request)
|
||||||
|
{
|
||||||
|
return await TorrentsCount(request);
|
||||||
|
}
|
||||||
|
|
||||||
[Authorize(Policy = "AuthSetting")]
|
[Authorize(Policy = "AuthSetting")]
|
||||||
[Route("torrents/files")]
|
[Route("torrents/files")]
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
|
|
@ -611,10 +639,17 @@ public class QBAuthLoginRequest
|
||||||
|
|
||||||
public class QBTorrentsInfoRequest
|
public class QBTorrentsInfoRequest
|
||||||
{
|
{
|
||||||
|
public String? Filter { get; set; }
|
||||||
public String? Category { get; set; }
|
public String? Category { get; set; }
|
||||||
public String? Hashes { get; set; }
|
public String? Hashes { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public class QBTorrentsCountRequest
|
||||||
|
{
|
||||||
|
public String? Filter { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
public class QBTorrentsHashRequest
|
public class QBTorrentsHashRequest
|
||||||
{
|
{
|
||||||
public String? Hash { get; set; }
|
public String? Hash { get; set; }
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue