Add torrents/trackers qBittorrent endpoint for cleanuparr compatibility.
This commit is contained in:
parent
7ec977b36e
commit
0b726792cb
4 changed files with 66 additions and 3 deletions
18
server/RdtClient.Data/Models/QBittorrent/Tracker.cs
Normal file
18
server/RdtClient.Data/Models/QBittorrent/Tracker.cs
Normal 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; }
|
||||||
|
}
|
||||||
|
|
@ -692,4 +692,25 @@ public class QBittorrent(ILogger<QBittorrent> logger, Settings settings, Authent
|
||||||
DlRateLimit = Settings.Get.DownloadClient.MaxSpeed
|
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}"
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -569,6 +569,30 @@ public class QBittorrentController(ILogger<QBittorrentController> logger, QBitto
|
||||||
{
|
{
|
||||||
return TransferInfo();
|
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
|
public class QBAuthLoginRequest
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
"windowsAuthentication": false,
|
"windowsAuthentication": false,
|
||||||
"anonymousAuthentication": true,
|
"anonymousAuthentication": true,
|
||||||
"iisExpress": {
|
"iisExpress": {
|
||||||
"applicationUrl": "http://localhost:6501/test"
|
"applicationUrl": "http://localhost:6501"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"profiles": {
|
"profiles": {
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
"commandName": "Project",
|
"commandName": "Project",
|
||||||
"environmentVariables": {
|
"environmentVariables": {
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development",
|
"ASPNETCORE_ENVIRONMENT": "Development",
|
||||||
"BASE_PATH": "test"
|
"BASE_PATH": ""
|
||||||
},
|
},
|
||||||
"applicationUrl": "http://localhost:6500"
|
"applicationUrl": "http://localhost:6500"
|
||||||
},
|
},
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
"launchUrl": "",
|
"launchUrl": "",
|
||||||
"environmentVariables": {
|
"environmentVariables": {
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development",
|
"ASPNETCORE_ENVIRONMENT": "Development",
|
||||||
"BASE_PATH": "test"
|
"BASE_PATH": ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue