From f476e847cea6805517d83c05c9991d8cbf44b8a3 Mon Sep 17 00:00:00 2001 From: Rishi Ghan Date: Tue, 12 Mar 2024 10:15:10 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=B2=20Added=20couple=20of=20torrent-re?= =?UTF-8?q?lated=20endpoints?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- services/qbittorrent.service.ts | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/services/qbittorrent.service.ts b/services/qbittorrent.service.ts index 9f23875..84974ac 100644 --- a/services/qbittorrent.service.ts +++ b/services/qbittorrent.service.ts @@ -12,6 +12,7 @@ export default class QBittorrentService extends Service { name: "qbittorrent", mixins: [], hooks: {}, + settings: {}, actions: { connect: { rest: "POST /connect", @@ -26,12 +27,16 @@ export default class QBittorrentService extends Service { }>, ) => { const { username, password, hostname, port, protocol } = ctx.params; + this.meta = new qBittorrentClient( `${protocol}://${hostname}:${port}`, `${username}`, `${password}`, ); console.log(this.meta); + if (this.meta) { + return { success: true, message: "Logged in successfully" }; + } }, }, getClientInfo: { @@ -102,8 +107,28 @@ export default class QBittorrentService extends Service { return Promise.all(torrentDetails); }, }, + checkForDeletedTorrents: { + rest: "GET /checkForDeletedTorrents", + handler: async (ctx: Context<{ infoHashes: [string] }>) => { + await this.broker.call("qbittorrent.connect", { + hostname: "localhost", + protocol: "http", + port: "8080", + username: "admin", + password: "password", + }); + const torrents: any = await this.broker.call("qbittorrent.getTorrents", {}); + const deletedTorrents = this.detectDeletedTorrents( + torrents.map((torrent: any) => torrent.hash), + ); + return deletedTorrents; + }, + }, }, - methods: {}, + methods: { + detectDeletedTorrents(currentHashes) {}, + }, + async started() {}, }); } }