Skip to content

Commit a2d3df4

Browse files
committed
feat: 优化 GitHub Actions 合并 PDF 时的文件名生成规则
原来使用简单的 `Aid` 或 `Pid` 进行命名,用户反馈导出的 PDF 名字全是数字看不出是什么。现在: 1. 默认情况下,本子维度的 PDF 命名为 `Atitle`,章节维度的 PDF 命名为 `Atitle_Ptitle`。 2. 新增可选的环境变量和 Action 面板输入参数 `PDF_NAME_RULE`,允许用户自定义生成规则。
1 parent 145af2a commit a2d3df4

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

.github/workflows/download_dispatch.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ on:
4040
- 是 | 本子维度合并pdf
4141
- 是 | 章节维度合并pdf
4242

43+
PDF_NAME_RULE:
44+
type: string
45+
description: PDF输出的文件名规则。默认本子维度的为'Atitle',章节维度的为'Atitle_Ptitle'
46+
default: ''
47+
required: false
48+
4349
ZIP_NAME:
4450
type: string
4551
default: 本子.tar.gz
@@ -78,6 +84,7 @@ jobs:
7884
UPLOAD_NAME: ${{ github.event.inputs.UPLOAD_NAME }}
7985
IMAGE_SUFFIX: ${{ github.event.inputs.IMAGE_SUFFIX }}
8086
PDF_OPTION: ${{ github.event.inputs.PDF_OPTION }}
87+
PDF_NAME_RULE: ${{ github.event.inputs.PDF_NAME_RULE }}
8188

8289
# 登录相关secrets
8390
JM_USERNAME: ${{ secrets.JM_USERNAME }}

usage/workflow_download.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,16 @@ def cover_option_config(option: JmOption):
8484
pdf_option = env('PDF_OPTION', None)
8585
if pdf_option and pdf_option != '否':
8686
call_when = 'after_album' if pdf_option == '是 | 本子维度合并pdf' else 'after_photo'
87+
88+
pdf_name_rule = env('PDF_NAME_RULE', None)
89+
if not pdf_name_rule:
90+
pdf_name_rule = 'Atitle' if call_when == 'after_album' else 'Atitle_Ptitle'
91+
8792
plugin = [{
8893
'plugin': Img2pdfPlugin.plugin_key,
8994
'kwargs': {
9095
'pdf_dir': option.dir_rule.base_dir + '/pdf/',
91-
'filename_rule': call_when[6].upper() + 'id',
96+
'filename_rule': pdf_name_rule,
9297
'delete_original_file': True,
9398
}
9499
}]

0 commit comments

Comments
 (0)