🏗️ Added torrent attrs to comic model

This commit is contained in:
2024-03-03 12:22:40 -05:00
parent 4cdb11fcbd
commit 7dbe2b2701
3 changed files with 49 additions and 7 deletions

View File

@@ -115,13 +115,13 @@ const ComicSchema = mongoose.Schema(
default: [], default: [],
}, },
}, },
torrent: { torrent: [
downloads: [], {
sourceApplication: String, infoHash: String,
magnet: String, name: String,
tracker: String, announce: [String],
status: String, },
}, ],
usenet: { usenet: {
sourceApplication: String, sourceApplication: String,
}, },

View File

@@ -23,6 +23,12 @@ const SettingsScehma = mongoose.Schema({
host: HostSchema, host: HostSchema,
}, },
}, },
prowlarr: {
client: {
host: HostSchema,
apiKey: String,
},
},
}); });
const Settings = mongoose.model("Settings", SettingsScehma); const Settings = mongoose.model("Settings", SettingsScehma);

View File

@@ -303,6 +303,7 @@ export default class ImportService extends Service {
); );
switch (ctx.params.importType) { switch (ctx.params.importType) {
case "new": case "new":
console.log(comicMetadata);
return await Comic.create(comicMetadata); return await Comic.create(comicMetadata);
case "update": case "update":
return await Comic.findOneAndUpdate( 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: { getComicBooks: {
rest: "POST /getComicBooks", rest: "POST /getComicBooks",
params: {}, params: {},