Skip to content

Commit ec7b087

Browse files
authored
v1.9.1: 增加禁漫网站默认的下载路径规则,优化Github Actions工作流 (#27)
1 parent 5f0243f commit ec7b087

File tree

6 files changed

+34
-76
lines changed

6 files changed

+34
-76
lines changed

.github/workflows/action_workflow.yml

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,15 @@ name: 下载JM本子
22

33
on:
44
push:
5-
branches: [ "workflow" ]
5+
branches: [ 'workflow', 'workflow_local' ]
66
paths:
77
- '.github/workflows/*.yml' # 工作流定义
88
- 'usage/**/*.py' # 工作流脚本
9-
- 'assets/config/*.yml' # 工作流配置
10-
pull_request:
11-
branches: [ "workflow" ]
9+
- 'assets/config/*.yml' # option配置文件
10+
- 'src/**/*.py' # 源码
1211

13-
permissions:
14-
contents: read
12+
pull_request:
13+
branches: [ 'workflow', 'workflow_local' ]
1514

1615
jobs:
1716
crawler:
@@ -23,12 +22,23 @@ jobs:
2322
with:
2423
python-version: "3.11"
2524

26-
- name: 安装依赖项
25+
- name: 安装依赖项(pip)
26+
if: ${{ github.ref == 'refs/heads/workflow' }}
2727
run: |
2828
python -m pip install --upgrade pip
2929
pip install jmcomic -i https://pypi.org/project --upgrade
3030
31+
- name: 安装依赖项(local)
32+
if: ${{ github.ref == 'refs/heads/workflow_local' }}
33+
run: |
34+
python -m pip install --upgrade pip
35+
pip install commonX -i https://pypi.org/project --upgrade
36+
pip install -e ./
37+
3138
- name: 运行下载脚本
39+
env:
40+
JM_USERNAME: ${{ secrets.JM_USERNAME }}
41+
JM_PASSWORD: ${{ secrets.JM_PASSWORD }}
3242
run: |
3343
cd ./usage/
3444
python jmcomic_workflows.py
@@ -41,11 +51,7 @@ jobs:
4151
- name: 上传结果
4252
uses: actions/upload-artifact@v3
4353
with:
44-
# Artifact name
4554
name: 下载完成的本子
46-
# A file, directory or wildcard pattern that describes what to upload
4755
path: /home/runner/work/jmcomic/下载完成的本子.tar.gz
48-
# The desired behavior if no files are found using the provided path.
4956
if-no-files-found: warn
50-
# Duration after which artifact will expire in days. 0 means using default retention.Minimum 1 day. Maximum 90 days unless changed from the repository settings page.
51-
retention-days: 90
57+
retention-days: 90

.github/workflows/action_workflow_local.yml

Lines changed: 0 additions & 61 deletions
This file was deleted.

assets/config/workflow_option.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ client_config:
2121
- cffi_Session
2222
meta_data:
2323
cookies: null
24+
impersonate: chrome110

src/jmcomic/__init__.py

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

5-
__version__ = '1.9.0'
5+
__version__ = '1.9.1'
66

77
from .api import *

src/jmcomic/jm_option.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ class DownloadDirTree:
8080
# 根目录 / Photo号 / 图片文件
8181
Bd_Id_Image = 5
8282

83+
# 根目录 / AlbumId / Photo序号 / 图片文件
84+
Bd_Id_Index_image = 6 # 禁漫网站的默认下载方式
85+
8386
AdditionalHandler = Callable[
8487
['DownloadDirTree', Optional[JmAlbumDetail], JmPhotoDetail],
8588
str
@@ -163,6 +166,10 @@ def photo_dir(flag_for_title):
163166

164167
return dirpath(None, photo_dir(4))
165168

169+
elif flag == 6:
170+
# 根目录 / AlbumId / Photo序号 / 图片文件
171+
return dirpath(photo.album_id, str(photo.album_index))
172+
166173
else:
167174
if flag in self.additional_tree_flag_handler_mapping:
168175
return self.additional_tree_flag_handler_mapping[flag](self, album, photo)

usage/jmcomic_workflows.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
# 下方填入你要下载的本子的id,一行一个。
22
# 每行的首尾可以有空白字符
33
jm_albums = '''
4-
380460
5-
4+
438696
65
76
87
'''
@@ -20,6 +19,12 @@ def get_option():
2019
client.enable_cache()
2120

2221
# 检查环境变量中是否有禁漫的用户名和密码,如果有则登录
22+
# 禁漫的大部分本子,下载是不需要登录的,少部分敏感题材需要登录
23+
# 如果你希望以登录状态下载本子,你需要自己配置一下Github Actions的 `secrets`
24+
# 配置的方式很简单,网页上点一点就可以了
25+
# 具体做法请去看官方教程:https://docs.github.com/en/actions/security-guides/encrypted-secrets
26+
27+
# 萌新注意!!!如果你想 `开源` 你的禁漫帐号,你也可以直接把账号密码写到下面的代码😅
2328

2429
def get_env(name):
2530
import os

0 commit comments

Comments
 (0)