From b38a746e67b3fef063e70321ed56859933ef46cb Mon Sep 17 00:00:00 2001 From: Mister-Hope Date: Mon, 12 Jan 2026 12:06:09 +0800 Subject: [PATCH 1/2] ci: update workflow and readme --- .github/workflows/build-release.yml | 65 +++++++++++++++++++++-------- .github/workflows/python-app.yml | 37 ++++++++-------- README.md | 43 +++++++++++-------- tchMaterial-parser.spec | 4 +- 4 files changed, 95 insertions(+), 54 deletions(-) diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index c891d06..91beb78 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -18,11 +18,13 @@ jobs: runs-on: windows-latest steps: - name: Checkout code - uses: actions/checkout@v5 + uses: actions/checkout@v6 + - name: Set up Python uses: actions/setup-python@v6 with: - python-version: '3.14' + python-version: "3.14" + - name: Install dependencies run: | python -m venv .venv @@ -30,11 +32,17 @@ jobs: python -m pip install --upgrade pip pip install pyinstaller pip install -r requirements.txt + - name: Build app with PyInstaller run: | - .venv\Scripts\pyinstaller ./tchMaterial-parser.spec + .venv\Scripts\activate + pyinstaller ./tchMaterial-parser.spec + + - name: Pack app + run: | cd dist mv tchMaterial-parser.exe tchMaterial-parser-windows-x64.exe + - name: Upload Release Asset uses: softprops/action-gh-release@v2 with: @@ -48,11 +56,13 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@v5 + uses: actions/checkout@v6 + - name: Set up Python uses: actions/setup-python@v6 with: - python-version: '3.14' + python-version: "3.14" + - name: Install dependencies run: | python -m venv .venv @@ -60,11 +70,17 @@ jobs: python -m pip install --upgrade pip pip install pyinstaller pip install -r requirements.txt + - name: Build app with PyInstaller run: | - .venv/bin/pyinstaller ./tchMaterial-parser.spec + source .venv/bin/activate + pyinstaller ./tchMaterial-parser.spec + + - name: Pack app + run: | cd dist mv tchMaterial-parser tchMaterial-parser-linux-x64 + - name: Upload Release Asset uses: softprops/action-gh-release@v2 with: @@ -74,15 +90,17 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} build-linux-arm64: - name: Build Linux ARM64 App + name: Build Linux Arm64 App runs-on: ubuntu-24.04-arm steps: - name: Checkout code - uses: actions/checkout@v5 + uses: actions/checkout@v6 + - name: Set up Python uses: actions/setup-python@v6 with: - python-version: '3.14' + python-version: "3.14" + - name: Install dependencies run: | python -m venv .venv @@ -90,11 +108,17 @@ jobs: python -m pip install --upgrade pip pip install pyinstaller pip install -r requirements.txt + - name: Build app with PyInstaller run: | - .venv/bin/pyinstaller ./tchMaterial-parser.spec + source .venv/bin/activate + pyinstaller ./tchMaterial-parser.spec + + - name: Pack app + run: | cd dist mv tchMaterial-parser tchMaterial-parser-linux-arm64 + - name: Upload Release Asset uses: softprops/action-gh-release@v2 with: @@ -103,16 +127,18 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - build-macos: - name: Build macOS ARM64 App + build-macos-arm64: + name: Build macOS Arm64 App runs-on: macos-latest steps: - name: Checkout code - uses: actions/checkout@v5 + uses: actions/checkout@v6 + - name: Set up Python uses: actions/setup-python@v6 with: - python-version: '3.14' + python-version: "3.14" + - name: Install dependencies run: | python -m venv .venv @@ -120,14 +146,17 @@ jobs: python -m pip install --upgrade pip pip install pyinstaller pip install -r requirements.txt + - name: Build app with PyInstaller run: | - .venv/bin/pyinstaller ./tchMaterial-parser.spec - - name: Create zip archive + source .venv/bin/activate + pyinstaller ./tchMaterial-parser.spec + + - name: Pack app run: | cd dist - mv tchMaterial-parser tchMaterial-parser-mac-arm64.app - zip -r tchMaterial-parser-mac-arm64.zip tchMaterial-parser-mac-arm64.app + /usr/bin/ditto -c -k --keepParent -rsrc tchMaterial-parser.app tchMaterial-parser-mac-arm64.zip + - name: Upload Release Asset uses: softprops/action-gh-release@v2 with: diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index feac45c..1f89cbd 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -5,9 +5,9 @@ name: Lint Code on: push: - branches: [ "main" ] + branches: ["main"] pull_request: - branches: [ "main" ] + branches: ["main"] permissions: contents: read @@ -16,18 +16,21 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v5 - - name: Set up Python 3.14 - uses: actions/setup-python@v6 - with: - python-version: "3.14" - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install flake8 - - name: Lint with flake8 - run: | - # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Checkout code + uses: actions/checkout@v6 + + - name: Set up Python + uses: actions/setup-python@v6 + with: + python-version: "3.14" + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install flake8 + - name: Lint with flake8 + run: | + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics diff --git a/README.md b/README.md index c9278db..ee83365 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ 本工具可以帮助您从[**国家中小学智慧教育平台**](https://basic.smartedu.cn/)获取电子课本的 PDF 文件网址并进行下载,让您更方便地获取课本内容。 -## ✨工具特点 +## ✨ 工具特点 - 📚**支持批量下载**:一次输入多个电子课本预览页面网址,即可批量下载 PDF 课本文件。 - 📂**自动命名文件**:工具会自动使用电子课本的名称作为文件名,方便管理下载的课本文件。 @@ -18,13 +18,16 @@ ![工具截图](./res/main.png) -## 📥工具下载与安装方法 +## 📥 工具下载与安装方法 ### GitHub Releases 本项目的 [GitHub Releases 页面](https://github.com/happycola233/tchMaterial-parser/releases)会发布**适用于 Windows、Linux 的 x86_64 架构**与**适用于 Linux、macOS 的 ARM64 架构**的程序。 -在下载完成之后,即可运行本程序,不需要额外的安装步骤。 +下载完成之后不需要额外的安装步骤。Windows 和 Linux 可直接运行本程序。 + +> [!WARNING] +> 由于没有签名,macOS 会报告文件已被损坏,需要先运行 `xattr -cr /path/to/tchMaterial-parser.app` 来移除应用的“隔离”属性。为了正确持久化 Access Token,建议将应用移动到 `/Applications` 目录下再运行。 ### Arch 用户软件仓库(AUR) @@ -36,9 +39,9 @@ yay -S tchmaterial-parser 感谢 [@iamzhz](https://github.com/iamzhz) 为本工具制作了发行包([#26](../../issues/26))! -## 🛠️使用方法 +## 🛠️ 使用方法 -### 1. ⌨️输入电子课本链接 +### 1. ⌨️ 输入电子课本链接 将电子课本的**预览页面网址**粘贴到工具文本框中,支持多个 URL(每行一个)。 @@ -48,7 +51,7 @@ yay -S tchmaterial-parser https://basic.smartedu.cn/tchMaterial/detail?contentType=assets_document&contentId=XXXXXX&catalogType=tchMaterial&subCatalog=tchMaterial ``` -### 2. 🔑设置 Access Token(可选) +### 2. 🔑 设置 Access Token(可选) > [!TIP] > 自 v3.1 版本起,这一步操作已经**不再必要**,当未设置 Access Token 时工具会使用其他方法下载资源。然而,这一方法**并不长期有效**,因此仍然建议您进行这一步操作。 @@ -58,24 +61,30 @@ https://basic.smartedu.cn/tchMaterial/detail?contentType=assets_document&content 3. 在控制台粘贴以下代码后回车(Enter): ```js - (function() { - const authKey = Object.keys(localStorage).find(key => key.startsWith("ND_UC_AUTH")); + (function () { + const authKey = Object.keys(localStorage).find((key) => + key.startsWith("ND_UC_AUTH"), + ); if (!authKey) { console.error("未找到 Access Token,请确保已登录!"); return; } const tokenData = JSON.parse(localStorage.getItem(authKey)); const accessToken = JSON.parse(tokenData.value).access_token; - console.log("%cAccess Token:", "color: green; font-weight: bold", accessToken); + console.log( + "%cAccess Token:", + "color: green; font-weight: bold", + accessToken, + ); })(); ``` - + 4. 复制控制台输出的 **Access Token**,然后在本工具中点击 “**设置 Token**” 按钮,粘贴并保存 Token。 > [!NOTE] > Access Token 可能会过期,若下载失败,请重新获取并设置新的 Token。 -### 3. 🚀开始下载 +### 3. 🚀 开始下载 点击 “**下载**” 按钮,工具将自动解析并下载 PDF 课本。 @@ -85,9 +94,9 @@ https://basic.smartedu.cn/tchMaterial/detail?contentType=assets_document&content ![添加了书签的 PDF 文件](./res/bookmark.png) -## ❓常见问题 +## ❓ 常见问题 -### 1. ⚠️为什么下载失败? +### 1. ⚠️ 为什么下载失败? - 如果您没有设置 Access Token,可能是本工具使用的方法失效了,请[**设置 Access Token**](#2-设置-access-token可选)🔑。 - 如果您设置了 Access Token,由于其具有时效性(一般为 7 天),因此极有可能是 Access Token 过期了,请重新获取新的 Access Token。 @@ -110,14 +119,14 @@ https://basic.smartedu.cn/tchMaterial/detail?contentType=assets_document&content [![Star History Chart](https://api.star-history.com/svg?repos=happycola233/tchMaterial-parser&type=Date)](https://star-history.com/#happycola233/tchMaterial-parser&Date) -## 🤝贡献指南 +## 🤝 贡献指南 如果您发现 Bug 或有改进建议,欢迎提交 **Issue** 或 **Pull Request**,让我们一起完善本工具! -## 📜许可证 +## 📜 许可证 本项目基于 [MIT 许可证](LICENSE),欢迎自由使用和二次开发。 -## 💌友情链接 +## 💌 友情链接 -- 📚您也可以在 [ChinaTextbook](https://github.com/TapXWorld/ChinaTextbook) 项目中下载归档的电子课本 PDF。 +- 📚 您也可以在 [ChinaTextbook](https://github.com/TapXWorld/ChinaTextbook) 项目中下载归档的电子课本 PDF。 diff --git a/tchMaterial-parser.spec b/tchMaterial-parser.spec index 6cb9a5d..66056f8 100644 --- a/tchMaterial-parser.spec +++ b/tchMaterial-parser.spec @@ -29,8 +29,8 @@ if is_mac: name='tchMaterial-parser', debug=False, bootloader_ignore_signals=False, - strip=False, - upx=True, + strip=True, + upx=False, console=False, disable_windowed_traceback=False, argv_emulation=False, From f0c883d52d0d3bba6d41137e09a38484d5183961 Mon Sep 17 00:00:00 2001 From: Mister-Hope Date: Mon, 12 Jan 2026 12:12:24 +0800 Subject: [PATCH 2/2] Update python-app.yml --- .github/workflows/python-app.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index 1f89cbd..2ec3884 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -28,6 +28,7 @@ jobs: run: | python -m pip install --upgrade pip pip install flake8 + - name: Lint with flake8 run: | # stop the build if there are Python syntax errors or undefined names