🏗️ Added torrent attrs to comic model
This commit is contained in:
@@ -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,
|
||||
},
|
||||
|
||||
@@ -23,6 +23,12 @@ const SettingsScehma = mongoose.Schema({
|
||||
host: HostSchema,
|
||||
},
|
||||
},
|
||||
prowlarr: {
|
||||
client: {
|
||||
host: HostSchema,
|
||||
apiKey: String,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const Settings = mongoose.model("Settings", SettingsScehma);
|
||||
|
||||
@@ -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: {},
|
||||
|
||||
Reference in New Issue
Block a user