From 27fa138ea5db4f714c5a29148ad982dc9c66a314 Mon Sep 17 00:00:00 2001
From: lyg <1543117173@qq.com>
Date: 星期二, 16 七月 2024 18:13:35 +0800
Subject: [PATCH] 修改无标题图书跳过

---
 src/main.mjs |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/main.mjs b/src/main.mjs
index 9a44efa..2fbe23a 100644
--- a/src/main.mjs
+++ b/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) => {

--
Gitblit v1.9.1