From b7df41ccb3037e556daccbb8e71758db192207b4 Mon Sep 17 00:00:00 2001
From: lyg <1543117173@qq.com>
Date: 星期日, 16 六月 2024 13:22:34 +0800
Subject: [PATCH] 增加生成已下载Excel文件功能

---
 src/main.mjs                |    1 -
 src/parse-log.mjs           |    3 +++
 src/gen-successed-excel.mjs |   29 +++++++++++++++++++++++++++++
 3 files changed, 32 insertions(+), 1 deletions(-)

diff --git a/src/gen-successed-excel.mjs b/src/gen-successed-excel.mjs
new file mode 100644
index 0000000..6d749dc
--- /dev/null
+++ b/src/gen-successed-excel.mjs
@@ -0,0 +1,29 @@
+import * as fs from 'fs';
+import xlsx from "node-xlsx";
+
+async function main() {
+  const dir = '';
+  const files = fs.readdirSync(dir);
+  const books = [];
+  const bookMap = {};
+  const workSheets = xlsx.parse("銆愮浜屾壒浜屾澶勭悊鍚庛�戜氦浠樻竻鍗�.xlsx");
+  const sheet = workSheets[0];
+  const data = sheet.data;
+  data[0][12] = '鏂囦欢鍚�';
+  data[0][13] = '鐘舵��';
+
+  for (const file of files) {
+    const ext = file.substring(file.lastIndexOf('.') + 1);
+    const name = file.substring(0, file.lastIndexOf('.'));
+    const [id, title] = name.split(' ');
+    bookMap[name] = { id, title, file };
+  }
+  for (const book of data.slice(1)) {
+    const _id = book[0] + ' ' + book[1];
+    const bookInfo = bookMap[_id];
+    if (bookInfo) {
+      book[12] = bookInfo.file;
+      book[13] = '浠ユ彁渚�';
+    }
+  }
+}
\ No newline at end of file
diff --git a/src/main.mjs b/src/main.mjs
index f8ec1c0..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";
diff --git a/src/parse-log.mjs b/src/parse-log.mjs
index 0976059..98ed4ea 100644
--- a/src/parse-log.mjs
+++ b/src/parse-log.mjs
@@ -82,4 +82,7 @@
 
   const noFileBooks = books.filter(book => !book.download && !book.downloadUrl).map(book => book.bookId).join('\n');
   fs.writeFileSync('./no-file-books.txt', noFileBooks);
+
+  const successBooks = books.filter(book => book.download).map(book => book.bookId).join('\n');
+  fs.writeFileSync('./success-books.txt', successBooks);
 }
\ No newline at end of file

--
Gitblit v1.9.1