| | |
| | | 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"; |
| | |
| | | */ |
| | | 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; |
| | | } |
| | |
| | | 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) => { |