Skip to content

重构插件的文件生成路径规则 (#437)#438

Merged
hect0x7 merged 6 commits intomasterfrom
dev
Jun 7, 2025
Merged

重构插件的文件生成路径规则 (#437)#438
hect0x7 merged 6 commits intomasterfrom
dev

Conversation

@hect0x7
Copy link
Owner

@hect0x7 hect0x7 commented Jun 7, 2025

Summary by CodeRabbit

  • New Features
    • Unified and flexible file path generation is now available across plugins, supporting customizable directory rules.
    • Added support for encrypted ZIP archives with password options, including random password generation.
    • Introduced new plugins for duplicate file detection and local web chapter viewing.
    • Automatic updating of mobile API domains for improved connectivity.
  • Bug Fixes
    • Improved safety when deleting directories by preventing removal if unrelated files are present.
    • Enhanced error handling in image-to-PDF conversion when no images are found.
  • Refactor
    • Plugins now use a consistent method for determining output file paths.
    • Directory rule parsing and application have been improved for more reliable path and filename generation.
  • Chores
    • Removed the obsolete JPG-to-PDF conversion plugin.
    • Updated plugin list and documentation to reflect plugin removals and additions.
    • Updated application version to 2.6.0.

@coderabbitai
Copy link

coderabbitai bot commented Jun 7, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This update adds automatic API domain list updating with secure fetching and decryption, updates API domain constants and version, renames and refactors directory rule parsing and path construction methods, unifies file path determination across plugins, adds zip encryption support, removes an obsolete plugin, improves directory deletion safety, updates plugin listings, and bumps the module version.

Changes

File(s) Change Summary
src/jmcomic/jm_config.py Added new constants and flags for API domain auto-update; updated API domain list and version; changed default 'impersonate' from 'chrome110' to 'chrome'.
src/jmcomic/jm_client_impl.py Added thread-safe automatic API domain list update method invoked during client initialization, replacing static domain list with fetched data.
src/jmcomic/jm_option.py Renamed and refactored DirRule methods for path/filename construction and rule DSL parsing; enhanced rule splitting and normalization.
src/jmcomic/jm_plugin.py Added unified file path logic via decide_filepath; added zip encryption support; removed ConvertJpgToPdfPlugin; improved deletion safety; updated Img2pdfPlugin and LongImgPlugin to use new path logic; minor robustness improvements.
README.md Removed one plugin, renamed another, and added two new plugins in the plugin list section.
assets/docs/sources/option_file_syntax.md Removed deprecated commented-out section describing the j2p plugin.
src/jmcomic/init.py Updated module version string from '2.5.39' to '2.6.0'.

Sequence Diagram(s)

sequenceDiagram
    participant Client as JmApiClient
    participant Postman
    participant CryptoTool
    participant Logger

    Client->>Client: after_init()
    alt FLAG_API_CLIENT_AUTO_UPDATE_DOMAIN is True
        Client->>Client: acquire client_update_domain_lock
        Client->>Postman: GET API_URL_DOMAIN_SERVER
        Postman-->>Client: encrypted_response
        Client->>CryptoTool: decode_resp_data(encrypted_response, API_DOMAIN_SERVER_SECRET)
        CryptoTool-->>Client: decrypted_json
        alt decrypted_json contains "Server"
            Client->>Client: update domain_list and global DOMAIN_API_LIST
            Client->>Logger: log success
        else
            Client->>Logger: log error (invalid response)
        end
        Client->>Client: set FLAG_API_CLIENT_AUTO_UPDATE_DOMAIN_DONE = True
        Client->>Client: release client_update_domain_lock
    end
Loading
sequenceDiagram
    participant Plugin as JmOptionPlugin (or subclass)
    participant DirRule
    participant FileSystem

    Plugin->>DirRule: apply_rule_to_path(album, photo, only_album_rules)
    DirRule-->>Plugin: constructed directory path
    Plugin->>DirRule: apply_rule_to_filename(album, photo, rule)
    DirRule-->>Plugin: constructed filename
    Plugin->>Plugin: decide_filepath(...) with dir_rule_dict or base_dir + filename_rule + suffix
    Plugin->>FileSystem: ensure directory exists, combine path components
Loading

Possibly related PRs

Poem

🐇 A secret key, a domain anew,
Rabbit hops to fetch what's true.
Paths are crafted, rules refined,
Old plugins gone, new ones aligned.
Zip locks tight with encrypted cheer,
In code’s green meadow, progress is near! 🌿✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 989aa66 and d101a2b.

📒 Files selected for processing (4)
  • src/jmcomic/__init__.py (1 hunks)
  • src/jmcomic/jm_client_impl.py (1 hunks)
  • src/jmcomic/jm_config.py (5 hunks)
  • src/jmcomic/jm_plugin.py (15 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need 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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 905f72c and af3ead1.

📒 Files selected for processing (3)
  • src/jmcomic/jm_config.py (2 hunks)
  • src/jmcomic/jm_option.py (4 hunks)
  • src/jmcomic/jm_plugin.py (10 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
src/jmcomic/jm_option.py (1)
src/jmcomic/jm_entity.py (1)
  • JmAlbumDetail (454-566)
src/jmcomic/jm_plugin.py (3)
usage/workflow_download.py (1)
  • decide_filepath (89-107)
src/jmcomic/jm_entity.py (2)
  • JmAlbumDetail (454-566)
  • JmPhotoDetail (292-451)
src/jmcomic/jm_option.py (3)
  • DirRule (60-168)
  • apply_rule_to_path (78-95)
  • apply_rule_to_filename (164-168)
🪛 Ruff (0.11.9)
src/jmcomic/jm_option.py

75-75: JmAlbumDetail may be undefined, or defined from star imports

(F405)


95-95: fix_filepath may be undefined, or defined from star imports

(F405)

src/jmcomic/jm_plugin.py

78-78: os may be undefined, or defined from star imports

(F405)


111-111: Optional may be undefined, or defined from star imports

(F405)


111-111: JmAlbumDetail may be undefined, or defined from star imports

(F405)


112-112: Optional may be undefined, or defined from star imports

(F405)


112-112: JmPhotoDetail may be undefined, or defined from star imports

(F405)


113-113: Optional may be undefined, or defined from star imports

(F405)


114-114: Optional may be undefined, or defined from star imports

(F405)


126-126: DirRule may be undefined, or defined from star imports

(F405)


128-128: os may be undefined, or defined from star imports

(F405)


130-130: os may be undefined, or defined from star imports

(F405)


131-131: os may be undefined, or defined from star imports

(F405)


131-131: DirRule may be undefined, or defined from star imports

(F405)


131-131: fix_suffix may be undefined, or defined from star imports

(F405)


133-133: mkdir_if_not_exists may be undefined, or defined from star imports

(F405)

🪛 Pylint (3.3.7)
src/jmcomic/jm_option.py

[error] 95-95: Undefined variable 'fix_filepath'

(E0602)

src/jmcomic/jm_plugin.py

[error] 78-78: Undefined variable 'os'

(E0602)


[refactor] 110-110: Too many arguments (7/5)

(R0913)


[refactor] 110-110: Too many positional arguments (7/5)

(R0917)


[error] 111-111: Undefined variable 'Optional'

(E0602)


[error] 112-112: Undefined variable 'Optional'

(E0602)


[error] 113-113: Undefined variable 'Optional'

(E0602)


[error] 114-114: Undefined variable 'Optional'

(E0602)


[error] 128-128: Undefined variable 'os'

(E0602)


[error] 130-130: Undefined variable 'os'

(E0602)


[error] 131-131: Undefined variable 'os'

(E0602)


[error] 131-131: Undefined variable 'fix_suffix'

(E0602)


[error] 133-133: Undefined variable 'mkdir_if_not_exists'

(E0602)


[refactor] 339-339: Redefining argument with the local name 'photo'

(R1704)

🔇 Additional comments (10)
src/jmcomic/jm_config.py (1)

383-383: LGTM! Simplified browser impersonation configuration.

The change from 'chrome110' to 'chrome' improves maintainability by avoiding version-specific browser impersonation. This makes the configuration more flexible and less likely to break with browser updates.

Also applies to: 419-419

src/jmcomic/jm_option.py (4)

73-73: Good refactoring: Method renamed for clarity.

The renaming from _build_path_from_rules to apply_rule_to_path improves API clarity and follows Python conventions by removing the underscore prefix for what appears to be a public method.

Also applies to: 76-76, 78-78


137-151: Improved rule parsing logic.

The rewritten split_rule_dsl method now:

  • Supports both '/' and '_' as delimiters, providing more flexibility
  • Properly trims whitespace from each rule element
  • Ensures the base directory rule is always the first element

This makes the directory rule parsing more robust and user-friendly.


164-164: Clear and descriptive method naming.

The renaming from apply_rule_directly to apply_rule_to_filename clearly indicates the method's purpose of applying rules specifically to filenames, improving code readability.

Also applies to: 168-168


95-95:

Details

✅ Verification successful

Verify fix_filepath import and parameter change.

The fix_filepath function is called without the is_dir parameter that was previously passed. Ensure this change is compatible with the function's signature.


🏁 Script executed:

#!/bin/bash
# Description: Verify fix_filepath function definition and usage

# Search for fix_filepath definition
ast-grep --pattern 'def fix_filepath($$$)'

# Search for other usages of fix_filepath to ensure consistency
rg -A 2 'fix_filepath\(' --type py

Length of output: 459


🏁 Script executed:

#!/bin/bash
# Display the import statements and top of the file to verify where fix_filepath comes from
head -n 30 src/jmcomic/jm_option.py

Length of output: 836


No issues with fix_filepath import or usage
The call to fix_filepath('/'.join(path_ls)) is valid—fix_filepath is brought in via the from .jm_client_impl import * at the top of jm_option.py, and its signature in jm_client_impl.py defines is_dir: bool = False, so omitting the second argument is safe.

🧰 Tools
🪛 Ruff (0.11.9)

95-95: fix_filepath may be undefined, or defined from star imports

(F405)

🪛 Pylint (3.3.7)

[error] 95-95: Undefined variable 'fix_filepath'

(E0602)

src/jmcomic/jm_plugin.py (5)

78-80: Excellent safety enhancement for directory deletion.

The added check prevents deletion of directories containing files not created by the current download, protecting user data. The informative log message helps users understand why deletion was skipped.

🧰 Tools
🪛 Ruff (0.11.9)

78-78: os may be undefined, or defined from star imports

(F405)

🪛 Pylint (3.3.7)

[error] 78-78: Undefined variable 'os'

(E0602)


318-318: Consistent integration with new filepath determination.

The ZipPlugin now uses the unified decide_filepath method and supports the dir_rule parameter, providing users with more flexible output path configuration options.

Also applies to: 335-335, 340-340


679-679: Improved error handling and consistent filepath management.

The plugin now:

  1. Supports flexible output paths via dir_rule parameter
  2. Uses the unified decide_filepath method
  3. Provides clear error logging when no images are found

These changes improve user experience and debugging.

Also applies to: 695-695, 721-723


740-740: Consistent updates and proper filter handling.

Good changes:

  1. Added dir_rule parameter for flexible output paths
  2. Uses unified decide_filepath method
  3. Converts filter to list, which is necessary for multiple iterations or length checks

Also applies to: 755-755, 774-774


670-729:

Details

❓ Verification inconclusive

Verify ConvertJpgToPdfPlugin removal rationale.

The AI summary mentions that ConvertJpgToPdfPlugin was removed. Since Img2pdfPlugin provides PDF conversion functionality, please confirm that all use cases of the removed plugin are covered.


🏁 Script executed:

#!/bin/bash
# Description: Check for any remaining references to ConvertJpgToPdfPlugin

# Search for any references to the removed plugin
rg -i 'ConvertJpgToPdfPlugin' --type py

# Search for any jpg2pdf or jpg_to_pdf references that might need attention
rg -i 'jpg.*pdf|jpeg.*pdf' --type py

Length of output: 78


No lingering references to ConvertJpgToPdfPlugin found.

A repository-wide search for ConvertJpgToPdfPlugin and related jpg→pdf patterns returned no matches, so the old class appears fully removed. Please manually confirm that Img2pdfPlugin provides all functionality previously offered by the removed plugin (e.g., page ordering, metadata preservation, custom filename rules) to ensure complete coverage.

🧰 Tools
🪛 Ruff (0.11.9)

674-674: JmPhotoDetail may be undefined, or defined from star imports

(F405)


675-675: JmAlbumDetail may be undefined, or defined from star imports

(F405)


684-684: jm_log may be undefined, or defined from star imports

(F405)


687-687: img2pdf imported but unused; consider using importlib.util.find_spec to test for availability

(F401)


705-705: JmAlbumDetail may be undefined, or defined from star imports

(F405)


705-705: JmPhotoDetail may be undefined, or defined from star imports

(F405)


716-716: files_of_dir may be undefined, or defined from star imports

(F405)

🪛 Pylint (3.3.7)

[refactor] 673-673: Too many arguments (8/5)

(R0913)


[refactor] 673-673: Too many positional arguments (8/5)

(R0917)


[error] 716-716: Undefined variable 'files_of_dir'

(E0602)

Comment on lines +109 to +135
# noinspection PyMethodMayBeStatic
def decide_filepath(self,
album: Optional[JmAlbumDetail],
photo: Optional[JmPhotoDetail],
filename_rule: str, suffix: str, base_dir: Optional[str],
dir_rule_dict: Optional[dict]
):
"""
根据规则计算一个文件的全路径

参数 dir_rule_dict 优先级最高,
如果 dir_rule_dict 不为空,优先用 dir_rule_dict
否则使用 base_dir + filename_rule + suffix
"""
filepath: str
base_dir: str
if dir_rule_dict is not None:
dir_rule = DirRule(**dir_rule_dict)
filepath = dir_rule.apply_rule_to_path(album, photo)
base_dir = os.path.dirname(filepath)
else:
base_dir = base_dir or os.getcwd()
filepath = os.path.join(base_dir, DirRule.apply_rule_to_filename(album, photo, filename_rule) + fix_suffix(suffix))

mkdir_if_not_exists(base_dir)
return filepath

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Well-designed filepath determination method.

The decide_filepath method provides a flexible interface for determining file paths, supporting both:

  1. Directory rule dictionaries for complex path generation
  2. Simple base directory + filename rule + suffix for basic cases

This unifies path generation logic across plugins.


🏁 Script executed:

#!/bin/bash
# Description: Verify the imports and usage of undefined symbols

# Check if DirRule is properly imported
rg -B 5 'class DirRule' --type py

# Check if fix_suffix is defined or imported
ast-grep --pattern 'def fix_suffix($$$)'

# Check if mkdir_if_not_exists is defined or imported
ast-grep --pattern 'def mkdir_if_not_exists($$$)'

Length of output: 375


Missing imports for utility functions

The decide_filepath implementation refers to fix_suffix and mkdir_if_not_exists, but neither is defined in this module nor imported. Please add the appropriate imports at the top of src/jmcomic/jm_plugin.py. For example:

--- a/src/jmcomic/jm_plugin.py
+++ b/src/jmcomic/jm_plugin.py
@@
-from .jm_option import DirRule
+from .jm_option import DirRule
+from jmcomic.utils import fix_suffix, mkdir_if_not_exists
  • Ensure the import path (jmcomic.utils) matches where these functions are actually defined.
  • Verify that both fix_suffix and mkdir_if_not_exists are available in the referenced module.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# noinspection PyMethodMayBeStatic
def decide_filepath(self,
album: Optional[JmAlbumDetail],
photo: Optional[JmPhotoDetail],
filename_rule: str, suffix: str, base_dir: Optional[str],
dir_rule_dict: Optional[dict]
):
"""
根据规则计算一个文件的全路径
参数 dir_rule_dict 优先级最高
如果 dir_rule_dict 不为空优先用 dir_rule_dict
否则使用 base_dir + filename_rule + suffix
"""
filepath: str
base_dir: str
if dir_rule_dict is not None:
dir_rule = DirRule(**dir_rule_dict)
filepath = dir_rule.apply_rule_to_path(album, photo)
base_dir = os.path.dirname(filepath)
else:
base_dir = base_dir or os.getcwd()
filepath = os.path.join(base_dir, DirRule.apply_rule_to_filename(album, photo, filename_rule) + fix_suffix(suffix))
mkdir_if_not_exists(base_dir)
return filepath
from .jm_option import DirRule
from jmcomic.utils import fix_suffix, mkdir_if_not_exists
🧰 Tools
🪛 Ruff (0.11.9)

111-111: Optional may be undefined, or defined from star imports

(F405)


111-111: JmAlbumDetail may be undefined, or defined from star imports

(F405)


112-112: Optional may be undefined, or defined from star imports

(F405)


112-112: JmPhotoDetail may be undefined, or defined from star imports

(F405)


113-113: Optional may be undefined, or defined from star imports

(F405)


114-114: Optional may be undefined, or defined from star imports

(F405)


126-126: DirRule may be undefined, or defined from star imports

(F405)


128-128: os may be undefined, or defined from star imports

(F405)


130-130: os may be undefined, or defined from star imports

(F405)


131-131: os may be undefined, or defined from star imports

(F405)


131-131: DirRule may be undefined, or defined from star imports

(F405)


131-131: fix_suffix may be undefined, or defined from star imports

(F405)


133-133: mkdir_if_not_exists may be undefined, or defined from star imports

(F405)

🪛 Pylint (3.3.7)

[refactor] 110-110: Too many arguments (7/5)

(R0913)


[refactor] 110-110: Too many positional arguments (7/5)

(R0917)


[error] 111-111: Undefined variable 'Optional'

(E0602)


[error] 112-112: Undefined variable 'Optional'

(E0602)


[error] 113-113: Undefined variable 'Optional'

(E0602)


[error] 114-114: Undefined variable 'Optional'

(E0602)


[error] 128-128: Undefined variable 'os'

(E0602)


[error] 130-130: Undefined variable 'os'

(E0602)


[error] 131-131: Undefined variable 'os'

(E0602)


[error] 131-131: Undefined variable 'fix_suffix'

(E0602)


[error] 133-133: Undefined variable 'mkdir_if_not_exists'

(E0602)

🤖 Prompt for AI Agents
In src/jmcomic/jm_plugin.py around lines 109 to 135, the functions fix_suffix
and mkdir_if_not_exists are used but not imported or defined in the file. To fix
this, add import statements at the top of the file to import fix_suffix and
mkdir_if_not_exists from their appropriate module, such as jmcomic.utils,
ensuring the import path matches where these functions are actually defined and
that they are available in that module.

Copy link

@coderabbitai coderabbitai bot left a 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

♻️ Duplicate comments (1)
src/jmcomic/jm_plugin.py (1)

110-135: ⚠️ Potential issue

Critical import issues prevent method execution.

This method references several undefined imports (Optional, os, DirRule, fix_suffix, mkdir_if_not_exists) that will cause runtime errors. As noted in previous reviews, these imports need to be added to the top of the file.

The method design itself is excellent - it provides a flexible interface for path determination with appropriate fallback logic and automatic directory creation.

🧰 Tools
🪛 Ruff (0.11.9)

112-112: Optional may be undefined, or defined from star imports

(F405)


112-112: JmAlbumDetail may be undefined, or defined from star imports

(F405)


113-113: Optional may be undefined, or defined from star imports

(F405)


113-113: JmPhotoDetail may be undefined, or defined from star imports

(F405)


114-114: Optional may be undefined, or defined from star imports

(F405)


115-115: Optional may be undefined, or defined from star imports

(F405)


127-127: DirRule may be undefined, or defined from star imports

(F405)


129-129: os may be undefined, or defined from star imports

(F405)


131-131: os may be undefined, or defined from star imports

(F405)


132-132: os may be undefined, or defined from star imports

(F405)


132-132: DirRule may be undefined, or defined from star imports

(F405)


132-132: fix_suffix may be undefined, or defined from star imports

(F405)


134-134: mkdir_if_not_exists may be undefined, or defined from star imports

(F405)

🪛 Pylint (3.3.7)

[refactor] 111-111: Too many arguments (7/5)

(R0913)


[refactor] 111-111: Too many positional arguments (7/5)

(R0917)


[error] 112-112: Undefined variable 'Optional'

(E0602)


[error] 113-113: Undefined variable 'Optional'

(E0602)


[error] 114-114: Undefined variable 'Optional'

(E0602)


[error] 115-115: Undefined variable 'Optional'

(E0602)


[error] 129-129: Undefined variable 'os'

(E0602)


[error] 131-131: Undefined variable 'os'

(E0602)


[error] 132-132: Undefined variable 'os'

(E0602)


[error] 132-132: Undefined variable 'fix_suffix'

(E0602)


[error] 134-134: Undefined variable 'mkdir_if_not_exists'

(E0602)

🧹 Nitpick comments (1)
src/jmcomic/jm_plugin.py (1)

307-474: Excellent encryption feature implementation with minor complexity concerns.

The ZipPlugin has been significantly enhanced with comprehensive encryption support including:

  • Multiple encryption backends (pyzipper, py7zr)
  • Random password generation with configurable length
  • Proper error handling for missing dependencies
  • Integration with the new unified path generation

The implementation is well-structured and feature-rich.

Consider extracting encryption logic into a separate helper class to reduce method complexity and improve testability, as some methods now exceed the recommended parameter count (7+ parameters).

🧰 Tools
🪛 Ruff (0.11.9)

317-317: JmAlbumDetail may be undefined, or defined from star imports

(F405)


318-318: JmPhotoDetail may be undefined, or defined from star imports

(F405)


335-335: JmcomicText may be undefined, or defined from star imports

(F405)


336-336: mkdir_if_not_exists may be undefined, or defined from star imports

(F405)


351-351: ExceptionTool may be undefined, or defined from star imports

(F405)


369-369: os may be undefined, or defined from star imports

(F405)


372-372: files_of_dir may be undefined, or defined from star imports

(F405)


373-373: os may be undefined, or defined from star imports

(F405)


374-374: os may be undefined, or defined from star imports

(F405)


382-382: fix_filepath may be undefined, or defined from star imports

(F405)


382-382: os may be undefined, or defined from star imports

(F405)


391-391: Use key in dict instead of key in dict.keys()

Remove .keys()

(SIM118)


396-396: files_of_dir may be undefined, or defined from star imports

(F405)


397-397: os may be undefined, or defined from star imports

(F405)


398-398: os may be undefined, or defined from star imports

(F405)


402-402: List may be undefined, or defined from star imports

(F405)


429-429: Optional may be undefined, or defined from star imports

(F405)

🪛 Pylint (3.3.7)

[refactor] 315-315: Too many arguments (11/5)

(R0913)


[refactor] 315-315: Too many positional arguments (11/5)

(R0917)


[refactor] 315-315: Too many local variables (16/15)

(R0914)


[error] 336-336: Undefined variable 'mkdir_if_not_exists'

(E0602)


[refactor] 346-346: Redefining argument with the local name 'photo'

(R1704)


[refactor] 363-363: Too many arguments (6/5)

(R0913)


[refactor] 363-363: Too many positional arguments (6/5)

(R0917)


[error] 369-369: Undefined variable 'os'

(E0602)


[error] 372-372: Undefined variable 'files_of_dir'

(E0602)


[error] 373-373: Undefined variable 'os'

(E0602)


[error] 374-374: Undefined variable 'os'

(E0602)


[error] 382-382: Undefined variable 'fix_filepath'

(E0602)


[error] 382-382: Undefined variable 'os'

(E0602)


[refactor] 384-384: Too many arguments (6/5)

(R0913)


[refactor] 384-384: Too many positional arguments (6/5)

(R0917)


[error] 396-396: Undefined variable 'files_of_dir'

(E0602)


[error] 397-397: Undefined variable 'os'

(E0602)


[error] 398-398: Undefined variable 'os'

(E0602)


[error] 402-402: Undefined variable 'List'

(E0602)


[error] 429-429: Undefined variable 'Optional'

(E0602)


[refactor] 435-459: Unnecessary "else" after "return", remove the "else" and de-indent the code inside it

(R1705)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between af3ead1 and 989aa66.

📒 Files selected for processing (4)
  • README.md (1 hunks)
  • assets/docs/sources/option_file_syntax.md (0 hunks)
  • src/jmcomic/__init__.py (1 hunks)
  • src/jmcomic/jm_plugin.py (15 hunks)
💤 Files with no reviewable changes (1)
  • assets/docs/sources/option_file_syntax.md
✅ Files skipped from review due to trivial changes (2)
  • src/jmcomic/init.py
  • README.md
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/jmcomic/jm_plugin.py (4)
usage/workflow_download.py (1)
  • decide_filepath (89-107)
src/jmcomic/jm_entity.py (2)
  • JmAlbumDetail (454-566)
  • JmPhotoDetail (292-451)
src/jmcomic/jm_option.py (6)
  • DirRule (60-168)
  • apply_rule_to_path (78-95)
  • apply_rule_to_filename (164-168)
  • decide_image_save_dir (69-73)
  • decide_image_save_dir (242-252)
  • decide_album_root_dir (75-76)
src/jmcomic/jm_exception.py (3)
  • ExceptionTool (69-191)
  • raises (83-107)
  • downloader (66-67)
🪛 Ruff (0.11.9)
src/jmcomic/jm_plugin.py

63-63: No explicit stacklevel keyword argument found

Set stacklevel=2

(B028)


79-79: os may be undefined, or defined from star imports

(F405)


112-112: Optional may be undefined, or defined from star imports

(F405)


112-112: JmAlbumDetail may be undefined, or defined from star imports

(F405)


113-113: Optional may be undefined, or defined from star imports

(F405)


113-113: JmPhotoDetail may be undefined, or defined from star imports

(F405)


114-114: Optional may be undefined, or defined from star imports

(F405)


115-115: Optional may be undefined, or defined from star imports

(F405)


127-127: DirRule may be undefined, or defined from star imports

(F405)


129-129: os may be undefined, or defined from star imports

(F405)


131-131: os may be undefined, or defined from star imports

(F405)


132-132: os may be undefined, or defined from star imports

(F405)


132-132: DirRule may be undefined, or defined from star imports

(F405)


132-132: fix_suffix may be undefined, or defined from star imports

(F405)


134-134: mkdir_if_not_exists may be undefined, or defined from star imports

(F405)


351-351: ExceptionTool may be undefined, or defined from star imports

(F405)


369-369: os may be undefined, or defined from star imports

(F405)


372-372: files_of_dir may be undefined, or defined from star imports

(F405)


373-373: os may be undefined, or defined from star imports

(F405)


374-374: os may be undefined, or defined from star imports

(F405)


429-429: Optional may be undefined, or defined from star imports

(F405)

🪛 Pylint (3.3.7)
src/jmcomic/jm_plugin.py

[error] 79-79: Undefined variable 'os'

(E0602)


[refactor] 111-111: Too many arguments (7/5)

(R0913)


[refactor] 111-111: Too many positional arguments (7/5)

(R0917)


[error] 112-112: Undefined variable 'Optional'

(E0602)


[error] 113-113: Undefined variable 'Optional'

(E0602)


[error] 114-114: Undefined variable 'Optional'

(E0602)


[error] 115-115: Undefined variable 'Optional'

(E0602)


[error] 129-129: Undefined variable 'os'

(E0602)


[error] 131-131: Undefined variable 'os'

(E0602)


[error] 132-132: Undefined variable 'os'

(E0602)


[error] 132-132: Undefined variable 'fix_suffix'

(E0602)


[error] 134-134: Undefined variable 'mkdir_if_not_exists'

(E0602)


[refactor] 346-346: Redefining argument with the local name 'photo'

(R1704)


[refactor] 363-363: Too many arguments (6/5)

(R0913)


[refactor] 363-363: Too many positional arguments (6/5)

(R0917)


[error] 369-369: Undefined variable 'os'

(E0602)


[error] 372-372: Undefined variable 'files_of_dir'

(E0602)


[error] 373-373: Undefined variable 'os'

(E0602)


[error] 374-374: Undefined variable 'os'

(E0602)


[refactor] 384-384: Too many arguments (6/5)

(R0913)


[refactor] 384-384: Too many positional arguments (6/5)

(R0917)


[error] 429-429: Undefined variable 'Optional'

(E0602)


[refactor] 435-459: Unnecessary "else" after "return", remove the "else" and de-indent the code inside it

(R1705)

🔇 Additional comments (4)
src/jmcomic/jm_plugin.py (4)

59-64: Enhanced flexibility for warning handling.

The addition of the throw parameter allows the method to optionally raise exceptions after issuing warnings, providing better control over error handling strategies while maintaining backward compatibility.

🧰 Tools
🪛 Ruff (0.11.9)

63-63: No explicit stacklevel keyword argument found

Set stacklevel=2

(B028)


79-81: Critical safety improvement for directory deletion.

The enhanced logic now checks if directories contain files before attempting deletion, preventing accidental data loss. This is a well-implemented safety measure that logs appropriate warnings when directories are skipped.

🧰 Tools
🪛 Ruff (0.11.9)

79-79: os may be undefined, or defined from star imports

(F405)

🪛 Pylint (3.3.7)

[error] 79-79: Undefined variable 'os'

(E0602)


750-850: Successful integration with unified path generation.

Both Img2pdfPlugin and LongImgPlugin have been cleanly updated to use the new decide_filepath method, maintaining their core functionality while gaining consistency with the overall architecture. The addition of error logging when no images are found improves user experience.

🧰 Tools
🪛 Ruff (0.11.9)

755-755: jm_log may be undefined, or defined from star imports

(F405)


758-758: img2pdf imported but unused; consider using importlib.util.find_spec to test for availability

(F401)


776-776: JmAlbumDetail may be undefined, or defined from star imports

(F405)


776-776: JmPhotoDetail may be undefined, or defined from star imports

(F405)


787-787: files_of_dir may be undefined, or defined from star imports

(F405)


805-805: JmPhotoDetail may be undefined, or defined from star imports

(F405)


806-806: JmAlbumDetail may be undefined, or defined from star imports

(F405)


815-815: jm_log may be undefined, or defined from star imports

(F405)


818-818: PIL.Image imported but unused; consider using importlib.util.find_spec to test for availability

(F401)


835-835: JmAlbumDetail may be undefined, or defined from star imports

(F405)


835-835: JmPhotoDetail may be undefined, or defined from star imports

(F405)


835-835: List may be undefined, or defined from star imports

(F405)


844-844: files_of_dir may be undefined, or defined from star imports

(F405)

🪛 Pylint (3.3.7)

[error] 787-787: Undefined variable 'files_of_dir'

(E0602)


[refactor] 804-804: Too many arguments (8/5)

(R0913)


[refactor] 804-804: Too many positional arguments (8/5)

(R0917)


[refactor] 835-835: Too many local variables (16/15)

(R0914)


[error] 835-835: Undefined variable 'List'

(E0602)


[error] 844-844: Undefined variable 'files_of_dir'

(E0602)


943-943: Appropriate suppression of false positive import warnings.

The noinspection comment is correctly used here since plugin_jm_server is an optional external dependency with proper ImportError handling in the surrounding code.

@hect0x7 hect0x7 merged commit 1679f00 into master Jun 7, 2025
@hect0x7 hect0x7 deleted the dev branch June 7, 2025 05:17
@coderabbitai coderabbitai bot mentioned this pull request Sep 21, 2025
Merged
@coderabbitai coderabbitai bot mentioned this pull request Feb 22, 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