diff --git a/library.ts b/library.ts index 44d2acb..e4818fb 100644 --- a/library.ts +++ b/library.ts @@ -72,19 +72,25 @@ on conflict(reader_url) return books; }, - async archive(path: string, outDir: string, book: Book) { + async archive( + path: string, + book: Book, + opts: { + outDir: string; + outAuthorsLimit: number; + }, + ) { const bookDir = await fs.stat(path); if (!bookDir.isDirectory()) { throw new Error(`Not found: ${path}`); } - const title = `${book.authors.join("、")}「${book.title}」`.replace( - /[/]/g, - "%2F", - ); + const title = `${book.authors + .slice(0, opts.outAuthorsLimit) + .join("、")}「${book.title}」`.replace(/[/]/g, "%2F"); - const out = createWriteStream(`${outDir}/${title}.cbz`); + const out = createWriteStream(`${opts.outDir}/${title}.cbz`); const zip = new Zip(function cb(err, data, final) { if (err) { diff --git a/main.ts b/main.ts index c51341c..a737723 100644 --- a/main.ts +++ b/main.ts @@ -13,6 +13,10 @@ const options = { type: "string", default: "dist", }, + "out-authors-limit": { + type: "string", + default: "3", + }, login: { type: "boolean", async run() { @@ -125,7 +129,10 @@ const options = { const platform = createPlatform({ db, browser }); const dir = `${args.values["out-dir"]!}/${book.id}`; await platform.download(dir, book); - await library.archive(dir, args.values["out-dir"]!, book); + await library.archive(dir, book, { + outDir: args.values["out-dir"]!, + outAuthorsLimit: Number(args.values["out-authors-limit"]!), + }); await browser.close(); } },