lyg
2024-07-16 27fa138ea5db4f714c5a29148ad982dc9c66a314
src/main.mjs
@@ -4,7 +4,6 @@
import path from "path";
import { Worker, isMainThread, parentPort, workerData, threadId } from 'worker_threads';
import { HttpsProxyAgent } from "https-proxy-agent";
import { resolve } from "path";
import { execFileSync } from "child_process";
import wordsjs from 'wordlist-js';
import usPlaceList from "./us-place-list.mjs";
@@ -43,7 +42,7 @@
 */
async function getPdfPages(filepath) {
  const buf = fs.readFileSync(filepath);
  const pdfDoc = await pdfLib.PDFDocument.load(buf);
  const pdfDoc = await pdfLib.PDFDocument.load(buf, { ignoreEncryption: true });
  const pages = pdfDoc.getPages().length;
  return pages;
}
@@ -315,7 +314,7 @@
    book.state = `下载完成`;
    book.format = ext;
    book.file = filepath;
    book.pages = await getPdfPages(filepath);
    book.pages = await getPdfPages(filepath).catch(() => 0);
    console.log(`下载完成:${filepath}`);
    return;
  }
@@ -344,7 +343,7 @@
          book.format = ext;
          book.file = filepath;
          book.url = url;
          book.pages = await getPdfPages(filepath);
          book.pages = await getPdfPages(filepath).catch(e => 0);
          resolve(true);
        });
        stream.on("error", (err) => {