Skip to content

Commit 49e6d26

Browse files
authored
v2.3.3: 实现移动端API的图片下载功能,重构异常机制,优化工作流 (#143)
1 parent ed83be0 commit 49e6d26

24 files changed

+463
-278
lines changed

.github/workflows/download.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: 下载JM本子
1+
name: 下载JM本子 (commit)
22

33
on:
44
workflow_dispatch:

.github/workflows/download_dispatch.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: 下载JM本子(dispatch)
1+
name: 下载JM本子 (dispatch)
22

33
on:
44
workflow_dispatch:
@@ -54,7 +54,7 @@ jobs:
5454
DIR_RULE: ${{ github.event.inputs.DIR_RULE }}
5555
ZIP_NAME: ${{ github.event.inputs.ZIP_NAME }}
5656
UPLOAD_NAME: ${{ github.event.inputs.UPLOAD_NAME }}
57-
# sccrets
57+
# secrets
5858
JM_USERNAME: ${{ secrets.JM_USERNAME }}
5959
JM_PASSWORD: ${{ secrets.JM_PASSWORD }}
6060
# 固定值

.github/workflows/release.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
name: 发布PYPI
1+
# publish when new release
2+
name: Publish If Release
23

34
on:
45
workflow_dispatch:
@@ -7,7 +8,7 @@ on:
78

89
jobs:
910
release:
10-
name: 构建并发布 jmcomic 到 PyPI
11+
name: Publish `jmcomic` to PYPI
1112
runs-on: ubuntu-latest
1213
steps:
1314
- uses: actions/checkout@v3
@@ -17,12 +18,12 @@ jobs:
1718
with:
1819
python-version: "3.11"
1920

20-
- name: 构建模块
21+
- name: Build
2122
run: |
2223
python -m pip install build
2324
python -m build
2425
25-
- name: 发布PYPI
26+
- name: Publish PYPI
2627
uses: pypa/gh-action-pypi-publish@release/v1
2728
with:
2829
password: ${{ secrets.PYPI_JMCOMIC }}

.github/workflows/release_auto.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
name: Release (auto)
2-
1+
# auto release and publish
2+
name: Auto Release & Publish
33

44
on:
55
workflow_dispatch:
@@ -30,7 +30,7 @@ jobs:
3030
tag_name: ${{ steps.tb.outputs.tag }}
3131
body: ${{ steps.tb.outputs.body }}
3232

33-
- name: Build Module
33+
- name: Build
3434
run: |
3535
python -m pip install build
3636
python -m build
Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: 跑测试
1+
name: Run Test (API)
22

33
on:
44
schedule:
@@ -9,8 +9,8 @@ on:
99
paths:
1010
- 'src/**/*.py'
1111
- 'tests/**/*.py'
12-
- '.github/workflows/test.yml'
13-
- 'assets/config/option_test.yml'
12+
- '.github/workflows/test_api.yml'
13+
- 'assets/config/option_test_api.yml'
1414

1515
jobs:
1616
test: # This code is based on https://github.com/gaogaotiantian/viztracer/blob/master/.github/workflows/python-package.yml
@@ -20,6 +20,9 @@ jobs:
2020
os: [ ubuntu-latest ]
2121
runs-on: ${{ matrix.os }}
2222
timeout-minutes: 5
23+
env:
24+
# 配置文件路径
25+
JM_OPTION_PATH_TEST: ./assets/config/option_test_api.yml
2326

2427
steps:
2528
- name: Checkout repository
@@ -31,28 +34,15 @@ jobs:
3134
python-version: ${{ matrix.python-version }}
3235

3336
- name: Install dependencies
34-
if: matrix.os != 'windows-latest'
3537
run: |
3638
python -m pip install --upgrade pip
3739
if [ -f requirements-dev.txt ]; then pip install -r requirements-dev.txt; fi
3840
39-
- name: Install dependencies on Windows
40-
if: matrix.os == 'windows-latest'
41-
run: |
42-
python -m pip install --upgrade pip
43-
if (Test-Path -Path '.\requirements-dev.txt' -PathType Leaf) {pip install -r requirements-dev.txt}
44-
4541
- name: Install local
4642
run: |
4743
pip install -e ./
4844
49-
- name: 跑测试
50-
if: matrix.os != 'windows-latest'
45+
- name: Run Test
5146
run: |
5247
cd ./tests/
5348
python -m unittest
54-
55-
- name: 跑测试(Windows系统)
56-
if: matrix.os == 'windows-latest'
57-
run: |
58-
python -m unittest discover -s ./tests -p "test_*.py"

.github/workflows/test_html.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Run Test (HTML)
2+
3+
on:
4+
schedule:
5+
- cron: "0 0 * * *"
6+
workflow_dispatch:
7+
push:
8+
branches: [ "dev" ]
9+
paths:
10+
- 'src/**/*.py'
11+
- 'tests/**/*.py'
12+
- '.github/workflows/test_html.yml'
13+
- 'assets/config/option_test_html.yml'
14+
15+
jobs:
16+
test: # This code is based on https://github.com/gaogaotiantian/viztracer/blob/master/.github/workflows/python-package.yml
17+
strategy:
18+
matrix:
19+
python-version: [ 3.7, 3.8, 3.9, "3.10", "3.11" ]
20+
os: [ ubuntu-latest ]
21+
runs-on: ${{ matrix.os }}
22+
timeout-minutes: 5
23+
env:
24+
# 配置文件路径
25+
JM_OPTION_PATH_TEST: ./assets/config/option_test_html.yml
26+
27+
steps:
28+
- name: Checkout repository
29+
uses: actions/checkout@v3
30+
31+
- name: Set up Python ${{ matrix.python-version }}
32+
uses: actions/setup-python@v4
33+
with:
34+
python-version: ${{ matrix.python-version }}
35+
36+
- name: Install dependencies
37+
run: |
38+
python -m pip install --upgrade pip
39+
if [ -f requirements-dev.txt ]; then pip install -r requirements-dev.txt; fi
40+
41+
- name: Install local
42+
run: |
43+
pip install -e ./
44+
45+
- name: Run Test
46+
run: |
47+
cd ./tests/
48+
python -m unittest

assets/config/option_test_api.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# GitHub Actions 测试用
2+
# 移动端配置
3+
4+
client:
5+
impl: api
6+
domain: [
7+
"www.jmapinode1.cc",
8+
"www.jmapinode2.cc",
9+
"www.jmapinode3.cc",
10+
"www.jmapibranch2.cc"
11+
]
12+
postman:
13+
meta_data:
14+
timeout: 10
15+
16+
# 插件配置
17+
plugin:
18+
after_init:
19+
- plugin: usage_log # 实时打印硬件占用率的插件
20+
kwargs:
21+
interval: 0.5 # 间隔时间
22+
enable_warning: false # 不告警

assets/config/option_test.yml renamed to assets/config/option_test_html.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
# GitHub Actions 测试用
2-
version: '2.0'
2+
# 网页端配置
33

44
client:
55
domain:
66
- jmcomic1.me
77
- jmcomic.me
8+
postman:
9+
meta_data:
10+
timeout: 10
811

912
# 插件配置
1013
plugin:

assets/config/常用配置介绍.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,13 @@ download:
3838
decode: true # JM的原图是混淆过的,要不要还原?
3939
suffix: .jpg # 把图片都转为.jpg格式
4040
threading:
41-
# batch_count: 章节的批量下载图片线程数
41+
# image: 同时下载的图片数,默认是30张图
4242
# 数值大,下得快,配置要求高,对禁漫压力大
4343
# 数值小,下得慢,配置要求低,对禁漫压力小
44-
# PS: 禁漫网页一般是一次请求50张图
45-
batch_count: 30
44+
# PS: 禁漫网页一次最多请求50张图
45+
image: 30
46+
# photo: 同时下载的章节数,不配置默认是cpu核心数
47+
photo: 16
4648

4749

4850

src/jmcomic/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# 被依赖方 <--- 使用方
33
# config <--- entity <--- toolkit <--- client <--- option <--- downloader
44

5-
__version__ = '2.3.2'
5+
__version__ = '2.3.3'
66

77
from .api import *
88
from .jm_plugin import *

0 commit comments

Comments
 (0)