Repository navigation
170 lines (143 loc) · 5.35 KB
/
Copy pathdownload_dispatch.yml
File metadata and controls
170 lines (143 loc) · 5.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
name: 下载JM本子 (dispatch)
on:
workflow_dispatch:
inputs:
JM_ALBUM_IDS:
type: string
description: 本子id(多个id用-隔开,如 '123-456-789')
required: false
JM_PHOTO_IDS:
type: string
description: 章节id(单独下载章节,多个id同上)
required: false
CLIENT_IMPL:
type: string
description: 客户端类型(client.impl),下载失败时,你可以尝试填入此项重试。'api' 表示移动端,'html' 表示网页端。
default: ''
required: false
IMAGE_SUFFIX:
type: string
description: 图片后缀(download.cache.suffix),默认为空,表示不做图片格式转换。可填入例如 'png' 'jpg'
default: ''
required: false
IMAGE_QUALITY:
type: number
description: 图片质量(1-99开启;100不压缩。此配置不支持后缀=PNG的图片。pdf模式会把图片转为JPEG压缩再合并pdf)
default: 100
required: false
DIR_RULE:
type: string
description: 下载文件夹规则(dir_rule.rule)。默认使用配置文件的 'Bd_Aauthor_Atitle_Pindex'。
default: ''
required: false
PDF_OPTION:
description: '是否要下载后将图片合并为pdf文件'
required: false
type: choice
options:
- 否
- 是 | 本子维度合并pdf
- 是 | 章节维度合并pdf
PDF_NAME_RULE:
type: string
description: 'PDF文件命名规则。支持字段如 Aid, Atitle, Pindex, Pid, Ptitle'
default: ''
required: false
ZIP_NAME:
type: string
default: 本子.tar.gz
description: 压缩文件名称
required: false
UPLOAD_NAME:
type: string
default: Click me to download
description: 上传文件名称
required: false
# JM_USERNAME:
# type: string
# default: ''
# description: '禁漫帐号(不建议使用,用户名和密码会泄露在日志中。最好用secrets)'
# required: false
#
# JM_PASSWORD:
# type: string
# default: ''
# description: '禁漫密码(不建议使用,用户名和密码会泄露在日志中。最好用secrets)'
# required: false
jobs:
crawler:
runs-on: ubuntu-latest
env:
# 工作流输入
JM_ALBUM_IDS: ${{ github.event.inputs.JM_ALBUM_IDS }}
JM_PHOTO_IDS: ${{ github.event.inputs.JM_PHOTO_IDS }}
DIR_RULE: ${{ github.event.inputs.DIR_RULE }}
CLIENT_IMPL: ${{ github.event.inputs.CLIENT_IMPL }}
ZIP_NAME: ${{ github.event.inputs.ZIP_NAME }}
UPLOAD_NAME: ${{ github.event.inputs.UPLOAD_NAME }}
IMAGE_SUFFIX: ${{ github.event.inputs.IMAGE_SUFFIX }}
IMAGE_QUALITY: ${{ github.event.inputs.IMAGE_QUALITY }}
PDF_OPTION: ${{ github.event.inputs.PDF_OPTION }}
PDF_NAME_RULE: ${{ github.event.inputs.PDF_NAME_RULE }}
# 登录相关secrets
JM_USERNAME: ${{ secrets.JM_USERNAME }}
JM_PASSWORD: ${{ secrets.JM_PASSWORD }}
# 邮件相关secrets
EMAIL_FROM: ${{ secrets.EMAIL_FROM }}
EMAIL_TO: ${{ secrets.EMAIL_TO }}
EMAIL_PASS: ${{ secrets.EMAIL_PASS }}
EMAIL_TITLE: ${{ secrets.EMAIL_TITLE }}
EMAIL_CONTENT: ${{ secrets.EMAIL_CONTENT }}
# 上游同步配置
UPSTREAM_REPO: 'hect0x7/JMComic-Crawler-Python'
UPSTREAM_REF: 'master'
# 固定值
JM_DOWNLOAD_DIR: /home/runner/work/jmcomic/download/
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install Dependency
run: |
python -m pip install --upgrade pip
pip install -r .github/requirements-dev.txt
- name: Install img2pdf
if: inputs.PDF_OPTION != '否'
run: |
pip install img2pdf
- name: 安装jmcomic(pip)
if: ${{ github.ref != 'refs/heads/dev' }}
run: |
pip install jmcomic -i https://pypi.org/project --upgrade
- name: 安装jmcomic(local)
if: ${{ github.ref == 'refs/heads/dev' }}
run: |
pip install -e ./
- name: Fork 同步上游下载脚本
if: ${{ github.repository != env.UPSTREAM_REPO || github.ref_name != env.UPSTREAM_REF }}
continue-on-error: true
run: |
curl --fail --silent --show-error --location \
"https://raw.githubusercontent.com/${{ env.UPSTREAM_REPO }}/${{ env.UPSTREAM_REF }}/usage/workflow_download.py" \
--output usage/upstream_workflow_download.py || true
if [ -f "usage/upstream_workflow_download.py" ] && [ -s "usage/upstream_workflow_download.py" ]; then
mv usage/upstream_workflow_download.py usage/workflow_download.py
fi
- name: 运行下载脚本
run: |
cd ./usage/
python workflow_download.py
- name: 压缩文件
run: |
cd $JM_DOWNLOAD_DIR
tar -zcvf "../$ZIP_NAME" ./
mv "../$ZIP_NAME" .
- name: 上传结果
uses: actions/upload-artifact@v4
with:
name: ${{ env.UPLOAD_NAME }}
path: ${{ env.JM_DOWNLOAD_DIR }}/${{ env.ZIP_NAME }}
if-no-files-found: error
retention-days: 90