Add torrents/trackers qBittorrent endpoint for cleanuparr compatibility.

This commit is contained in:
Roger Far 2026-03-01 11:24:11 -07:00
parent 7ec977b36e
commit 0b726792cb
4 changed files with 66 additions and 3 deletions

View file

@ -0,0 +1,18 @@
using System.Text.Json.Serialization;
namespace RdtClient.Data.Models.QBittorrent;
public class Tracker
{
[JsonPropertyName("url")]
public required String Url { get; set; }
[JsonPropertyName("status")]
public required String Status { get; set; }
[JsonPropertyName("num_peers")]
public required Int64 NumPeers { get; set; }
[JsonPropertyName("msg")]
public required String Msg { get; set; }
}

View file

@ -692,4 +692,25 @@ public class QBittorrent(ILogger<QBittorrent> logger, Settings settings, Authent
DlRateLimit = Settings.Get.DownloadClient.MaxSpeed
};
}
public async Task<List<Tracker>> TorrentsTrackers(String hash)
{
var torrent = await torrents.GetByHash(hash);
if (torrent == null || torrent.Type != DownloadType.Torrent)
{
return [];
}
return
[
new()
{
Url = $"http://{torrent.RdHost ?? torrent.ClientKind.ToString()}/**".ToLower(),
Status = "Working",
NumPeers = torrent.RdSeeders ?? 1,
Msg = $"Fake Tracker for {torrent.ClientKind}"
}
];
}
}

View file

@ -569,6 +569,30 @@ public class QBittorrentController(ILogger<QBittorrentController> logger, QBitto
{
return TransferInfo();
}
[Authorize(Policy = "AuthSetting")]
[Route("torrents/trackers")]
[HttpGet]
[HttpPost]
public async Task<ActionResult<IList<TorrentInfo>>> TorrentsTrackers([FromQuery] QBTorrentsHashRequest request)
{
if (String.IsNullOrWhiteSpace(request.Hash))
{
return BadRequest();
}
var results = await qBittorrent.TorrentsTrackers(request.Hash);
return Ok(results);
}
[Authorize(Policy = "AuthSetting")]
[Route("torrents/trackers")]
[HttpPost]
public async Task<ActionResult<IList<TorrentInfo>>> TorrentsTrackersPost([FromForm] QBTorrentsHashRequest request)
{
return await TorrentsTrackers(request);
}
}
public class QBAuthLoginRequest

View file

@ -4,7 +4,7 @@
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:6501/test"
"applicationUrl": "http://localhost:6501"
}
},
"profiles": {
@ -12,7 +12,7 @@
"commandName": "Project",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"BASE_PATH": "test"
"BASE_PATH": ""
},
"applicationUrl": "http://localhost:6500"
},
@ -22,7 +22,7 @@
"launchUrl": "",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"BASE_PATH": "test"
"BASE_PATH": ""
}
}
}