From 7ac5cdb777822f293db0d7266bc75b912ad38ffa Mon Sep 17 00:00:00 2001 From: Rishi Ghan Date: Sun, 3 Mar 2024 12:20:01 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=8F=97=EF=B8=8F=20Adding=20comments?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- services/qbittorrent.service.ts | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/services/qbittorrent.service.ts b/services/qbittorrent.service.ts index 89752a8..3790f2c 100644 --- a/services/qbittorrent.service.ts +++ b/services/qbittorrent.service.ts @@ -57,14 +57,15 @@ export default class QBittorrentService extends Service { }>, ) => { try { - const { torrentToDownload } = ctx.params; + const { torrentToDownload, comicObjectId } = ctx.params; console.log(torrentToDownload); const response = await fetch(torrentToDownload, { method: "GET", }); + // Read the buffer to a file const buffer = await response.arrayBuffer(); writeFileSync(`mithrandir.torrent`, Buffer.from(buffer)); - + // Add the torrent to qbittorrent's queue, paused. const result = await this.meta.torrents.add({ torrents: { buffer: readFileSync("mithrandir.torrent"), @@ -72,10 +73,18 @@ export default class QBittorrentService extends Service { // start this torrent in a paused state (see Torrent type for options) paused: true, }); - + const { name, infoHash, announce } = parseTorrent( + readFileSync("mithrandir.torrent"), + ); + await this.broker.call("library.applyTorrentDownloadMetadata", { + name, + torrentToDownload, + comicObjectId, + announce, + infoHash, + }); return { result, - metadata: parseTorrent(readFileSync("mithrandir.torrent")), }; } catch (err) { console.error(err);