Skip to content

Commit b38a746

Browse files
committed
ci: update workflow and readme
1 parent 5858183 commit b38a746

File tree

4 files changed

+95
-54
lines changed

4 files changed

+95
-54
lines changed

.github/workflows/build-release.yml

Lines changed: 47 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,31 @@ jobs:
1818
runs-on: windows-latest
1919
steps:
2020
- name: Checkout code
21-
uses: actions/checkout@v5
21+
uses: actions/checkout@v6
22+
2223
- name: Set up Python
2324
uses: actions/setup-python@v6
2425
with:
25-
python-version: '3.14'
26+
python-version: "3.14"
27+
2628
- name: Install dependencies
2729
run: |
2830
python -m venv .venv
2931
.venv\Scripts\activate
3032
python -m pip install --upgrade pip
3133
pip install pyinstaller
3234
pip install -r requirements.txt
35+
3336
- name: Build app with PyInstaller
3437
run: |
35-
.venv\Scripts\pyinstaller ./tchMaterial-parser.spec
38+
.venv\Scripts\activate
39+
pyinstaller ./tchMaterial-parser.spec
40+
41+
- name: Pack app
42+
run: |
3643
cd dist
3744
mv tchMaterial-parser.exe tchMaterial-parser-windows-x64.exe
45+
3846
- name: Upload Release Asset
3947
uses: softprops/action-gh-release@v2
4048
with:
@@ -48,23 +56,31 @@ jobs:
4856
runs-on: ubuntu-latest
4957
steps:
5058
- name: Checkout code
51-
uses: actions/checkout@v5
59+
uses: actions/checkout@v6
60+
5261
- name: Set up Python
5362
uses: actions/setup-python@v6
5463
with:
55-
python-version: '3.14'
64+
python-version: "3.14"
65+
5666
- name: Install dependencies
5767
run: |
5868
python -m venv .venv
5969
source .venv/bin/activate
6070
python -m pip install --upgrade pip
6171
pip install pyinstaller
6272
pip install -r requirements.txt
73+
6374
- name: Build app with PyInstaller
6475
run: |
65-
.venv/bin/pyinstaller ./tchMaterial-parser.spec
76+
source .venv/bin/activate
77+
pyinstaller ./tchMaterial-parser.spec
78+
79+
- name: Pack app
80+
run: |
6681
cd dist
6782
mv tchMaterial-parser tchMaterial-parser-linux-x64
83+
6884
- name: Upload Release Asset
6985
uses: softprops/action-gh-release@v2
7086
with:
@@ -74,27 +90,35 @@ jobs:
7490
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7591

7692
build-linux-arm64:
77-
name: Build Linux ARM64 App
93+
name: Build Linux Arm64 App
7894
runs-on: ubuntu-24.04-arm
7995
steps:
8096
- name: Checkout code
81-
uses: actions/checkout@v5
97+
uses: actions/checkout@v6
98+
8299
- name: Set up Python
83100
uses: actions/setup-python@v6
84101
with:
85-
python-version: '3.14'
102+
python-version: "3.14"
103+
86104
- name: Install dependencies
87105
run: |
88106
python -m venv .venv
89107
source .venv/bin/activate
90108
python -m pip install --upgrade pip
91109
pip install pyinstaller
92110
pip install -r requirements.txt
111+
93112
- name: Build app with PyInstaller
94113
run: |
95-
.venv/bin/pyinstaller ./tchMaterial-parser.spec
114+
source .venv/bin/activate
115+
pyinstaller ./tchMaterial-parser.spec
116+
117+
- name: Pack app
118+
run: |
96119
cd dist
97120
mv tchMaterial-parser tchMaterial-parser-linux-arm64
121+
98122
- name: Upload Release Asset
99123
uses: softprops/action-gh-release@v2
100124
with:
@@ -103,31 +127,36 @@ jobs:
103127
env:
104128
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
105129

106-
build-macos:
107-
name: Build macOS ARM64 App
130+
build-macos-arm64:
131+
name: Build macOS Arm64 App
108132
runs-on: macos-latest
109133
steps:
110134
- name: Checkout code
111-
uses: actions/checkout@v5
135+
uses: actions/checkout@v6
136+
112137
- name: Set up Python
113138
uses: actions/setup-python@v6
114139
with:
115-
python-version: '3.14'
140+
python-version: "3.14"
141+
116142
- name: Install dependencies
117143
run: |
118144
python -m venv .venv
119145
source .venv/bin/activate
120146
python -m pip install --upgrade pip
121147
pip install pyinstaller
122148
pip install -r requirements.txt
149+
123150
- name: Build app with PyInstaller
124151
run: |
125-
.venv/bin/pyinstaller ./tchMaterial-parser.spec
126-
- name: Create zip archive
152+
source .venv/bin/activate
153+
pyinstaller ./tchMaterial-parser.spec
154+
155+
- name: Pack app
127156
run: |
128157
cd dist
129-
mv tchMaterial-parser tchMaterial-parser-mac-arm64.app
130-
zip -r tchMaterial-parser-mac-arm64.zip tchMaterial-parser-mac-arm64.app
158+
/usr/bin/ditto -c -k --keepParent -rsrc tchMaterial-parser.app tchMaterial-parser-mac-arm64.zip
159+
131160
- name: Upload Release Asset
132161
uses: softprops/action-gh-release@v2
133162
with:

.github/workflows/python-app.yml

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ name: Lint Code
55

66
on:
77
push:
8-
branches: [ "main" ]
8+
branches: ["main"]
99
pull_request:
10-
branches: [ "main" ]
10+
branches: ["main"]
1111

1212
permissions:
1313
contents: read
@@ -16,18 +16,21 @@ jobs:
1616
build:
1717
runs-on: ubuntu-latest
1818
steps:
19-
- uses: actions/checkout@v5
20-
- name: Set up Python 3.14
21-
uses: actions/setup-python@v6
22-
with:
23-
python-version: "3.14"
24-
- name: Install dependencies
25-
run: |
26-
python -m pip install --upgrade pip
27-
pip install flake8
28-
- name: Lint with flake8
29-
run: |
30-
# stop the build if there are Python syntax errors or undefined names
31-
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
32-
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
33-
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
19+
- name: Checkout code
20+
uses: actions/checkout@v6
21+
22+
- name: Set up Python
23+
uses: actions/setup-python@v6
24+
with:
25+
python-version: "3.14"
26+
27+
- name: Install dependencies
28+
run: |
29+
python -m pip install --upgrade pip
30+
pip install flake8
31+
- name: Lint with flake8
32+
run: |
33+
# stop the build if there are Python syntax errors or undefined names
34+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
35+
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
36+
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics

README.md

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
本工具可以帮助您从[**国家中小学智慧教育平台**](https://basic.smartedu.cn/)获取电子课本的 PDF 文件网址并进行下载,让您更方便地获取课本内容。
88

9-
## ✨工具特点
9+
## 工具特点
1010

1111
- 📚**支持批量下载**:一次输入多个电子课本预览页面网址,即可批量下载 PDF 课本文件。
1212
- 📂**自动命名文件**:工具会自动使用电子课本的名称作为文件名,方便管理下载的课本文件。
@@ -18,13 +18,16 @@
1818

1919
![工具截图](./res/main.png)
2020

21-
## 📥工具下载与安装方法
21+
## 📥 工具下载与安装方法
2222

2323
### GitHub Releases
2424

2525
本项目的 [GitHub Releases 页面](https://github.com/happycola233/tchMaterial-parser/releases)会发布**适用于 Windows、Linux 的 x86_64 架构****适用于 Linux、macOS 的 ARM64 架构**的程序。
2626

27-
在下载完成之后,即可运行本程序,不需要额外的安装步骤。
27+
下载完成之后不需要额外的安装步骤。Windows 和 Linux 可直接运行本程序。
28+
29+
> [!WARNING]
30+
> 由于没有签名,macOS 会报告文件已被损坏,需要先运行 `xattr -cr /path/to/tchMaterial-parser.app` 来移除应用的“隔离”属性。为了正确持久化 Access Token,建议将应用移动到 `/Applications` 目录下再运行。
2831
2932
### Arch 用户软件仓库(AUR)
3033

@@ -36,9 +39,9 @@ yay -S tchmaterial-parser
3639

3740
感谢 [@iamzhz](https://github.com/iamzhz) 为本工具制作了发行包([#26](../../issues/26))!
3841

39-
## 🛠️使用方法
42+
## 🛠️ 使用方法
4043

41-
### 1. ⌨️输入电子课本链接
44+
### 1. ⌨️ 输入电子课本链接
4245

4346
将电子课本的**预览页面网址**粘贴到工具文本框中,支持多个 URL(每行一个)。
4447

@@ -48,7 +51,7 @@ yay -S tchmaterial-parser
4851
https://basic.smartedu.cn/tchMaterial/detail?contentType=assets_document&contentId=XXXXXX&catalogType=tchMaterial&subCatalog=tchMaterial
4952
```
5053

51-
### 2. 🔑设置 Access Token(可选)
54+
### 2. 🔑 设置 Access Token(可选)
5255

5356
> [!TIP]
5457
> 自 v3.1 版本起,这一步操作已经**不再必要**,当未设置 Access Token 时工具会使用其他方法下载资源。然而,这一方法**并不长期有效**,因此仍然建议您进行这一步操作。
@@ -58,24 +61,30 @@ https://basic.smartedu.cn/tchMaterial/detail?contentType=assets_document&content
5861
3. 在控制台粘贴以下代码后回车(Enter):
5962

6063
```js
61-
(function() {
62-
const authKey = Object.keys(localStorage).find(key => key.startsWith("ND_UC_AUTH"));
64+
(function () {
65+
const authKey = Object.keys(localStorage).find((key) =>
66+
key.startsWith("ND_UC_AUTH"),
67+
);
6368
if (!authKey) {
6469
console.error("未找到 Access Token,请确保已登录!");
6570
return;
6671
}
6772
const tokenData = JSON.parse(localStorage.getItem(authKey));
6873
const accessToken = JSON.parse(tokenData.value).access_token;
69-
console.log("%cAccess Token:", "color: green; font-weight: bold", accessToken);
74+
console.log(
75+
"%cAccess Token:",
76+
"color: green; font-weight: bold",
77+
accessToken,
78+
);
7079
})();
7180
```
72-
81+
7382
4. 复制控制台输出的 **Access Token**,然后在本工具中点击 “**设置 Token**” 按钮,粘贴并保存 Token。
7483

7584
> [!NOTE]
7685
> Access Token 可能会过期,若下载失败,请重新获取并设置新的 Token。
7786
78-
### 3. 🚀开始下载
87+
### 3. 🚀 开始下载
7988

8089
点击 “**下载**” 按钮,工具将自动解析并下载 PDF 课本。
8190

@@ -85,9 +94,9 @@ https://basic.smartedu.cn/tchMaterial/detail?contentType=assets_document&content
8594

8695
![添加了书签的 PDF 文件](./res/bookmark.png)
8796

88-
## ❓常见问题
97+
## 常见问题
8998

90-
### 1. ⚠️为什么下载失败
99+
### 1. ⚠️ 为什么下载失败
91100

92101
- 如果您没有设置 Access Token,可能是本工具使用的方法失效了,请[**设置 Access Token**](#2-设置-access-token可选)🔑。
93102
- 如果您设置了 Access Token,由于其具有时效性(一般为 7 天),因此极有可能是 Access Token 过期了,请重新获取新的 Access Token。
@@ -110,14 +119,14 @@ https://basic.smartedu.cn/tchMaterial/detail?contentType=assets_document&content
110119

111120
[![Star History Chart](https://api.star-history.com/svg?repos=happycola233/tchMaterial-parser&type=Date)](https://star-history.com/#happycola233/tchMaterial-parser&Date)
112121

113-
## 🤝贡献指南
122+
## 🤝 贡献指南
114123

115124
如果您发现 Bug 或有改进建议,欢迎提交 **Issue****Pull Request**,让我们一起完善本工具!
116125

117-
## 📜许可证
126+
## 📜 许可证
118127

119128
本项目基于 [MIT 许可证](LICENSE),欢迎自由使用和二次开发。
120129

121-
## 💌友情链接
130+
## 💌 友情链接
122131

123-
- 📚您也可以在 [ChinaTextbook](https://github.com/TapXWorld/ChinaTextbook) 项目中下载归档的电子课本 PDF。
132+
- 📚 您也可以在 [ChinaTextbook](https://github.com/TapXWorld/ChinaTextbook) 项目中下载归档的电子课本 PDF。

tchMaterial-parser.spec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ if is_mac:
2929
name='tchMaterial-parser',
3030
debug=False,
3131
bootloader_ignore_signals=False,
32-
strip=False,
33-
upx=True,
32+
strip=True,
33+
upx=False,
3434
console=False,
3535
disable_windowed_traceback=False,
3636
argv_emulation=False,

0 commit comments

Comments
 (0)