Skip to content

feat: 优化 GitHub Actions 合并 PDF 时的文件名生成规则 (#91)#529

Closed
hect0x7 wants to merge 1 commit intomasterfrom
fix-pdf-sort
Closed

feat: 优化 GitHub Actions 合并 PDF 时的文件名生成规则 (#91)#529
hect0x7 wants to merge 1 commit intomasterfrom
fix-pdf-sort

Conversation

@hect0x7
Copy link
Copy Markdown
Owner

@hect0x7 hect0x7 commented Apr 16, 2026

修复并优化了 GitHub Actions 工作流在启用 PDF 合并时的行为:

原本在使用 Actions 进行本子下载并导出 PDF 时,filename_rule 被强编码映射为 AidPid,导致最后生成的 PDF 文件名都是数字。

此 PR 进行了以下修改:

  • 将默认文件命名规则变为更人性化的形式:
    • “本子维度合并pdf”下的默认文件名为 Atitle
    • “章节维度合并pdf”下的默认文件名为 Atitle_Ptitle
  • 通过在 download_dispatch.yml 中新增选项 PDF_NAME_RULE,将该设定暴露在 Actions 面板,允许用户自定义基于自身偏好的 PDF 文件命名规则。

参考 Issue:#91

Summary by CodeRabbit

Release Notes

  • New Features
    • Added customizable PDF output filename rule to control how generated PDFs are named based on merge mode (book/section), providing enhanced flexibility in PDF generation workflows.

原来使用简单的 `Aid` 或 `Pid` 进行命名,用户反馈导出的 PDF 名字全是数字看不出是什么。现在:

1. 默认情况下,本子维度的 PDF 命名为 `Atitle`,章节维度的 PDF 命名为 `Atitle_Ptitle`。

2. 新增可选的环境变量和 Action 面板输入参数 `PDF_NAME_RULE`,允许用户自定义生成规则。
@github-actions
Copy link
Copy Markdown

To prevent beginners from mistakenly submitting PRs,
if your PR only modifies the usage/workflow_download.py file,
it will be automatically closed.
If you really want to submit a PR, please reopen it yourself.
Make sure you know what you are doing!

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 16, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 287933ce-32b1-4b04-8190-fdd6ee6f7eea

📥 Commits

Reviewing files that changed from the base of the PR and between 145af2a and a2d3df4.

📒 Files selected for processing (2)
  • .github/workflows/download_dispatch.yml
  • usage/workflow_download.py

📝 Walkthrough

Walkthrough

The changes introduce a new PDF_NAME_RULE workflow input to GitHub Actions that allows dynamic configuration of PDF filename rules during workflow dispatch. This input is passed as an environment variable to the Python workflow script, where it overrides the default PDF naming behavior in the PDF generation configuration.

Changes

Cohort / File(s) Summary
GitHub Actions Workflow Configuration
.github/workflows/download_dispatch.yml
Added PDF_NAME_RULE workflow_dispatch input (string, optional) with description noting defaults vary by PDF merge mode. Input is passed to job environment as PDF_NAME_RULE for downstream usage.
Python Workflow Script
usage/workflow_download.py
Enhanced cover_option_config() to use environment variable PDF_NAME_RULE for controlling Img2pdfPlugin's filename rule. Replaced hardcoded derivation with conditional logic that defaults to 'Atitle' for album context and 'Atitle_Ptitle' otherwise.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • Dev #489: Directly modifies the same PDF generation configuration in usage/workflow_download.py, introducing the environment-driven PDF_NAME_RULE override that replaces prior filename rule derivation logic.

Poem

🐰 A rule for PDFs, so fine and neat,
From workflows dispatched, now bittersweet—
The filename dances to config's tune,
No more hardcoded, just nature's boon! 📄✨

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-pdf-sort

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot closed this Apr 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant