mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-02-09 03:37:45 +03:00
feat: get seed status
This commit is contained in:
parent
9c9c0e6c09
commit
c556a00e4a
@ -123,6 +123,16 @@ export class PythonInstance {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static async getSeedStatus() {
|
||||||
|
const response = await this.rpc.get<LibtorrentPayload[] | null>(
|
||||||
|
"/seed-status"
|
||||||
|
);
|
||||||
|
|
||||||
|
if (response.data === null) return [];
|
||||||
|
|
||||||
|
return response.data;
|
||||||
|
}
|
||||||
|
|
||||||
static async pauseDownload() {
|
static async pauseDownload() {
|
||||||
await this.rpc
|
await this.rpc
|
||||||
.post("/action", {
|
.post("/action", {
|
||||||
|
@ -25,6 +25,7 @@ export interface LibtorrentPayload {
|
|||||||
numPeers: number;
|
numPeers: number;
|
||||||
numSeeds: number;
|
numSeeds: number;
|
||||||
downloadSpeed: number;
|
downloadSpeed: number;
|
||||||
|
uploadSpeed: number;
|
||||||
bytesDownloaded: number;
|
bytesDownloaded: number;
|
||||||
fileSize: number;
|
fileSize: number;
|
||||||
folderName: string;
|
folderName: string;
|
||||||
|
@ -10,6 +10,7 @@ export const startMainLoop = async () => {
|
|||||||
watchProcesses(),
|
watchProcesses(),
|
||||||
DownloadManager.watchDownloads(),
|
DownloadManager.watchDownloads(),
|
||||||
AchievementWatcherManager.watchAchievements(),
|
AchievementWatcherManager.watchAchievements(),
|
||||||
|
DownloadManager.getSeedStatus(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
await sleep(1500);
|
await sleep(1500);
|
||||||
|
@ -50,6 +50,20 @@ class Handler(BaseHTTPRequestHandler):
|
|||||||
|
|
||||||
self.wfile.write(json.dumps(status).encode('utf-8'))
|
self.wfile.write(json.dumps(status).encode('utf-8'))
|
||||||
|
|
||||||
|
elif self.path == "/seed-status":
|
||||||
|
if self.headers.get(self.rpc_password_header) != rpc_password:
|
||||||
|
self.send_response(401)
|
||||||
|
self.end_headers()
|
||||||
|
return
|
||||||
|
|
||||||
|
self.send_response(200)
|
||||||
|
self.send_header("Content-type", "application/json")
|
||||||
|
self.end_headers()
|
||||||
|
|
||||||
|
status = torrent_downloader.get_seed_status()
|
||||||
|
|
||||||
|
self.wfile.write(json.dumps(status).encode('utf-8'))
|
||||||
|
|
||||||
elif self.path == "/healthcheck":
|
elif self.path == "/healthcheck":
|
||||||
self.send_response(200)
|
self.send_response(200)
|
||||||
self.end_headers()
|
self.end_headers()
|
||||||
|
Loading…
Reference in New Issue
Block a user