From 7dbe2b27015661f1f417d2b70856a01fb18f8eb5 Mon Sep 17 00:00:00 2001 From: Rishi Ghan Date: Sun, 3 Mar 2024 12:22:40 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=8F=97=EF=B8=8F=20Added=20torrent=20attrs?= =?UTF-8?q?=20to=20comic=20model?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/comic.model.ts | 14 +++++++------- models/settings.model.ts | 6 ++++++ services/library.service.ts | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 7 deletions(-) diff --git a/models/comic.model.ts b/models/comic.model.ts index 8778cd6..7dbd06f 100644 --- a/models/comic.model.ts +++ b/models/comic.model.ts @@ -115,13 +115,13 @@ const ComicSchema = mongoose.Schema( default: [], }, }, - torrent: { - downloads: [], - sourceApplication: String, - magnet: String, - tracker: String, - status: String, - }, + torrent: [ + { + infoHash: String, + name: String, + announce: [String], + }, + ], usenet: { sourceApplication: String, }, diff --git a/models/settings.model.ts b/models/settings.model.ts index a60f75d..73a4422 100644 --- a/models/settings.model.ts +++ b/models/settings.model.ts @@ -23,6 +23,12 @@ const SettingsScehma = mongoose.Schema({ host: HostSchema, }, }, + prowlarr: { + client: { + host: HostSchema, + apiKey: String, + }, + }, }); const Settings = mongoose.model("Settings", SettingsScehma); diff --git a/services/library.service.ts b/services/library.service.ts index ce198d8..26ae9b2 100644 --- a/services/library.service.ts +++ b/services/library.service.ts @@ -303,6 +303,7 @@ export default class ImportService extends Service { ); switch (ctx.params.importType) { case "new": + console.log(comicMetadata); return await Comic.create(comicMetadata); case "update": return await Comic.findOneAndUpdate( @@ -424,6 +425,41 @@ export default class ImportService extends Service { }); }, }, + applyTorrentDownloadMetadata: { + rest: "POST /applyTorrentDownloadMetadata", + handler: async ( + ctx: Context<{ + torrentToDownload: any; + comicObjectId: String; + infoHash: String; + name: String; + announce: [String]; + }> + ) => { + const { + name, + torrentToDownload, + comicObjectId, + announce, + infoHash, + } = ctx.params; + console.log(JSON.stringify(ctx.params, null, 4)); + + return await Comic.findByIdAndUpdate( + new ObjectId(comicObjectId), + { + $push: { + "acquisition.torrent": { + infoHash, + name, + announce, + }, + }, + }, + { new: true, safe: true, upsert: true } + ); + }, + }, getComicBooks: { rest: "POST /getComicBooks", params: {},