🔧 Added a download -> library import endpoint
This commit is contained in:
@@ -47,7 +47,7 @@ import {
|
|||||||
walkFolder,
|
walkFolder,
|
||||||
getSizeOfDirectory,
|
getSizeOfDirectory,
|
||||||
} from "../utils/file.utils";
|
} from "../utils/file.utils";
|
||||||
import { uncompressEntireArchive } from "../utils/uncompression.utils";
|
import { extractFromArchive, uncompressEntireArchive } from "../utils/uncompression.utils";
|
||||||
import { convertXMLToJSON } from "../utils/xml.utils";
|
import { convertXMLToJSON } from "../utils/xml.utils";
|
||||||
import {
|
import {
|
||||||
IExtractComicBookCoverErrorResponse,
|
IExtractComicBookCoverErrorResponse,
|
||||||
@@ -319,6 +319,25 @@ export default class ImportService extends Service {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
importDownloadedFileToLibrary: {
|
||||||
|
rest: "POST /importDownloadedFileToLibrary",
|
||||||
|
params: {},
|
||||||
|
handler: async (ctx: Context<{ comicObjectId: string; downloadStatus: { name: string; } }>) => {
|
||||||
|
console.log("miscommunicate");
|
||||||
|
console.log(
|
||||||
|
JSON.stringify(ctx.params, null, 2)
|
||||||
|
);
|
||||||
|
const result = await extractFromArchive(
|
||||||
|
`${COMICS_DIRECTORY}/${ctx.params.downloadStatus.name}`
|
||||||
|
);
|
||||||
|
console.log(result);
|
||||||
|
await Comic.findOneAndUpdate({ _id: new ObjectId(ctx.params.comicObjectId) }, {
|
||||||
|
rawFileDetails: {
|
||||||
|
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
getComicBooks: {
|
getComicBooks: {
|
||||||
rest: "POST /getComicBooks",
|
rest: "POST /getComicBooks",
|
||||||
|
|||||||
@@ -28,9 +28,7 @@ export default class SocketService extends Service {
|
|||||||
},
|
},
|
||||||
action: async (data, ack) => {
|
action: async (data, ack) => {
|
||||||
// write your handler function here.
|
// write your handler function here.
|
||||||
console.log(
|
|
||||||
JSON.stringify(data, null, 2)
|
|
||||||
);
|
|
||||||
|
|
||||||
switch (data.type) {
|
switch (data.type) {
|
||||||
case "LS_IMPORT":
|
case "LS_IMPORT":
|
||||||
@@ -52,7 +50,9 @@ export default class SocketService extends Service {
|
|||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case "LS_SINGLE_IMPORT":
|
case "LS_SINGLE_IMPORT":
|
||||||
console.log(data.data);
|
console.info("AirDC++ finished a download -> ")
|
||||||
|
|
||||||
|
await this.broker.call("library.importDownloadedFileToLibrary", data.data, {});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user