🏗️ 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: [],
},
},
torrent: {
downloads: [],
sourceApplication: String,
magnet: String,
tracker: String,
status: String,
},
torrent: [
{
infoHash: String,
name: String,
announce: [String],
},
],
usenet: {
sourceApplication: String,
},

View File

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

View File

@@ -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: {},