-
Notifications
You must be signed in to change notification settings - Fork 9.9k
v2.6.4: 本子详情增加description字段,img2pdf插件支持设置pdf密码 #458
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughThis update introduces optional PDF encryption support to the img2pdf plugin, allowing users to specify a password for generated PDFs. The Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Img2pdfPlugin
participant PDFWriter
participant PikePDF
User->>Img2pdfPlugin: invoke(photo, album, ..., encrypt)
Img2pdfPlugin->>PDFWriter: write_img_2_pdf(pdf_filepath, album, photo, encrypt)
PDFWriter->>PDFWriter: img2pdf.convert(images)
alt encrypt is provided
PDFWriter->>PikePDF: encrypt_pdf(pdf_filepath, encrypt)
PikePDF->>PDFWriter: Save encrypted PDF
end
PDFWriter-->>Img2pdfPlugin: return
Img2pdfPlugin-->>User: return
Possibly related PRs
Poem
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/jmcomic/jm_plugin.py (1)
804-814: PDF encryption implementation is robust.The
encrypt_pdfmethod includes proper error handling for missing dependencies and uses the appropriatepikepdflibrary for PDF encryption. The password extraction from the encrypt dictionary is handled safely.Consider whether logging the password might be a security concern:
password = str(encrypt.get('password', '')) +# Note: Password is logged for debugging purposes with pikepdf.open(pdf_filepath, allow_overwriting_input=True) as pdf: pdf.save(pdf_filepath, encryption=pikepdf.Encryption(user=password, owner=password))If this is intentional for debugging, consider adding a comment. Otherwise, you might want to avoid logging sensitive information.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
assets/docs/sources/option_file_syntax.md(1 hunks)src/jmcomic/__init__.py(1 hunks)src/jmcomic/jm_entity.py(1 hunks)src/jmcomic/jm_plugin.py(3 hunks)src/jmcomic/jm_toolkit.py(2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/jmcomic/jm_plugin.py (1)
src/jmcomic/jm_entity.py (2)
JmAlbumDetail(454-568)JmPhotoDetail(292-451)
🪛 Ruff (0.12.2)
src/jmcomic/jm_plugin.py
777-777: JmAlbumDetail may be undefined, or defined from star imports
(F405)
777-777: JmPhotoDetail may be undefined, or defined from star imports
(F405)
🔇 Additional comments (10)
src/jmcomic/__init__.py (1)
5-5: Version bump looks correct.The version increment to 2.6.4 appropriately reflects the new features added in this PR (description field and PDF encryption support).
assets/docs/sources/option_file_syntax.md (1)
282-283: Documentation update looks good.The addition of the
encryptparameter documentation with a clear example helps users understand how to configure PDF password protection for the img2pdf plugin.src/jmcomic/jm_toolkit.py (2)
29-29: Regex pattern for description extraction looks correct.The pattern
r'叙述:([\s\S]*?)</h2>'appropriately captures album descriptions from HTML content using a non-greedy match to extract text between "叙述:" and the closing</h2>tag.
655-655: Field adapter extension is properly implemented.Adding 'description' to the JmAlbumDetail field adapter correctly enables extraction and mapping of album descriptions from API data into the album entity.
src/jmcomic/jm_entity.py (2)
472-472: Constructor parameter addition is well-designed.The optional
descriptionparameter with a default empty string maintains backward compatibility while enabling the new functionality.
478-478: Description processing follows established patterns.The description field is processed consistently with other string fields using
str(description).strip(), maintaining code consistency.src/jmcomic/jm_plugin.py (4)
752-752: Encrypt parameter addition maintains backward compatibility.The optional
encryptparameter is well-designed, allowing users to opt into PDF encryption without breaking existing functionality.
770-770: Parameter passing is correctly implemented.The
encryptparameter is properly passed through to thewrite_img_2_pdfmethod, maintaining the chain of data flow.
799-800: Conditional encryption is properly implemented.The encryption is appropriately applied only when the
encryptparameter is provided, with proper control flow.
777-777: Verified availability of JmAlbumDetail and JmPhotoDetail via star-import chainBoth types are defined in
src/jmcomic/jm_entity.pyand are pulled intojm_plugin.pythrough the following chain offrom *.import *statements:
- jm_plugin.py:
from .jm_option import *- jm_option.py:
from .jm_client_impl import *- jm_client_impl.py → jm_client_interface.py → jm_toolkit.py → jm_exception.py → jm_entity.py
Since
jm_entity.pydeclaresclass JmAlbumDetailandclass JmPhotoDetail, they’re available at runtime and for type checkers. No changes required.
Summary by CodeRabbit
New Features
Documentation
Other