Merge pull request #141 from Edouard-chin/ec-filter-torrents-by-category

Filter torrents with the category query string:
This commit is contained in:
Roger Far 2022-04-30 11:12:29 -06:00 committed by GitHub
commit 2cff8ec0a6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.IO; using System.IO;
using System.Net.Http; using System.Net.Http;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -135,10 +136,20 @@ namespace RdtClient.Web.Controllers
[Route("torrents/info")] [Route("torrents/info")]
[HttpGet] [HttpGet]
[HttpPost] [HttpPost]
public async Task<ActionResult<IList<TorrentInfo>>> TorrentsInfo() public async Task<ActionResult<IList<TorrentInfo>>> TorrentsInfo([FromQuery] QBTorrentsHashRequest request)
{ {
var result = await _qBittorrent.TorrentInfo(); var results = await _qBittorrent.TorrentInfo();
return Ok(result); IList<TorrentInfo> filteredResults = new List<TorrentInfo>();
if (request.Category == null) {
filteredResults = results;
} else if (request.Category == "") {
filteredResults = results.Where(m => m.Category == null).ToList();
} else {
filteredResults = results.Where(m => m.Category == request.Category).ToList();
}
return Ok(filteredResults);
} }
[Authorize] [Authorize]
@ -450,6 +461,7 @@ namespace RdtClient.Web.Controllers
public class QBTorrentsHashRequest public class QBTorrentsHashRequest
{ {
public String Hash { get; set; } public String Hash { get; set; }
public String Category { get; set; }
} }
public class QBTorrentsDeleteRequest public class QBTorrentsDeleteRequest