From 9e1941a1afe86c1623d6942b1a8cb87a8ddc6609 Mon Sep 17 00:00:00 2001
From: hect0x7 <93357912+hect0x7@users.noreply.github.com>
Date: Thu, 17 Jul 2025 21:48:24 +0800
Subject: [PATCH 1/4] =?UTF-8?q?pdf=E6=8F=92=E4=BB=B6=E6=94=AF=E6=8C=81?=
=?UTF-8?q?=E5=8A=A0=E5=AF=86=20[skip=20ci]?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/jmcomic/jm_plugin.py | 22 +++++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)
diff --git a/src/jmcomic/jm_plugin.py b/src/jmcomic/jm_plugin.py
index 2f64dae0..1f88b436 100644
--- a/src/jmcomic/jm_plugin.py
+++ b/src/jmcomic/jm_plugin.py
@@ -129,7 +129,8 @@ def decide_filepath(self,
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))
+ 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
@@ -749,6 +750,7 @@ def invoke(self,
filename_rule='Pid',
dir_rule=None,
delete_original_file=False,
+ encrypt=None,
**kwargs,
):
if photo is None and album is None:
@@ -766,14 +768,14 @@ def invoke(self,
pdf_filepath = self.decide_filepath(album, photo, filename_rule, 'pdf', pdf_dir, dir_rule)
# 调用 img2pdf 把 photo_dir 下的所有图片转为pdf
- img_path_ls, img_dir_ls = self.write_img_2_pdf(pdf_filepath, album, photo)
+ img_path_ls, img_dir_ls = self.write_img_2_pdf(pdf_filepath, album, photo, encrypt)
self.log(f'Convert Successfully: JM{album or photo} → {pdf_filepath}')
# 执行删除
img_path_ls += img_dir_ls
self.execute_deletion(img_path_ls)
- def write_img_2_pdf(self, pdf_filepath, album: JmAlbumDetail, photo: JmPhotoDetail):
+ def write_img_2_pdf(self, pdf_filepath, album: JmAlbumDetail, photo: JmPhotoDetail, encrypt):
import img2pdf
if album is None:
@@ -795,8 +797,22 @@ def write_img_2_pdf(self, pdf_filepath, album: JmAlbumDetail, photo: JmPhotoDeta
with open(pdf_filepath, 'wb') as f:
f.write(img2pdf.convert(img_path_ls))
+ if encrypt:
+ self.encrypt_pdf(pdf_filepath, encrypt)
+
return img_path_ls, img_dir_ls
+ def encrypt_pdf(self, pdf_filepath: str, encrypt: dict):
+ try:
+ import pikepdf
+ except ImportError:
+ self.warning_lib_not_install('pikepdf')
+ return
+
+ password = encrypt['password']
+ with pikepdf.open(pdf_filepath, allow_overwriting_input=True) as pdf:
+ pdf.save(pdf_filepath, encryption=pikepdf.Encryption(user=password, owner=password))
+
class LongImgPlugin(JmOptionPlugin):
plugin_key = 'long_img'
From d9a5c9120b7064ac38f51fcd3f9d170752968a87 Mon Sep 17 00:00:00 2001
From: hect0x7 <93357912+hect0x7@users.noreply.github.com>
Date: Fri, 18 Jul 2025 00:02:25 +0800
Subject: [PATCH 2/4] =?UTF-8?q?=E5=A2=9E=E5=8A=A0description=20(#457)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/jmcomic/jm_entity.py | 2 ++
src/jmcomic/jm_plugin.py | 2 +-
src/jmcomic/jm_toolkit.py | 2 ++
3 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/jmcomic/jm_entity.py b/src/jmcomic/jm_entity.py
index ed1d0fb1..8742a65a 100644
--- a/src/jmcomic/jm_entity.py
+++ b/src/jmcomic/jm_entity.py
@@ -469,11 +469,13 @@ def __init__(self,
authors,
tags,
related_list=None,
+ description='',
):
super().__init__()
self.album_id: str = str(album_id)
self.scramble_id: str = str(scramble_id)
self.name: str = str(name).strip()
+ self.description = str(description).strip()
self.page_count: int = int(page_count) # 总页数
self.pub_date: str = pub_date # 发布日期
self.update_date: str = update_date # 更新日期
diff --git a/src/jmcomic/jm_plugin.py b/src/jmcomic/jm_plugin.py
index 1f88b436..a1726ddc 100644
--- a/src/jmcomic/jm_plugin.py
+++ b/src/jmcomic/jm_plugin.py
@@ -809,7 +809,7 @@ def encrypt_pdf(self, pdf_filepath: str, encrypt: dict):
self.warning_lib_not_install('pikepdf')
return
- password = encrypt['password']
+ password = str(encrypt.get('password', ''))
with pikepdf.open(pdf_filepath, allow_overwriting_input=True) as pdf:
pdf.save(pdf_filepath, encryption=pikepdf.Encryption(user=password, owner=password))
diff --git a/src/jmcomic/jm_toolkit.py b/src/jmcomic/jm_toolkit.py
index 3bb39b98..e5eada1f 100644
--- a/src/jmcomic/jm_toolkit.py
+++ b/src/jmcomic/jm_toolkit.py
@@ -26,6 +26,7 @@ class JmcomicText:
pattern_html_album_album_id = compile(r'.*?:JM(\d+)')
pattern_html_album_scramble_id = compile(r'var scramble_id = (\d+);')
pattern_html_album_name = compile(r'id="book-name"[^>]*?>([\s\S]*?)<')
+ pattern_html_album_description = compile(r'叙述:([\s\S]*?)')
pattern_html_album_episode_list = compile(r'data-album="(\d+)"[^>]*>[\s\S]*?第(\d+)[话話]([\s\S]*?)<[\s\S]*?>')
pattern_html_album_page_count = compile(r'.*?:(\d+)')
pattern_html_album_pub_date = compile(r'>上架日期 : (.*?)')
@@ -651,6 +652,7 @@ class JmApiAdaptTool:
'actors',
'related_list',
'name',
+ 'description',
('id', 'album_id'),
('author', 'authors'),
('total_views', 'views'),
From 07d067d158275df776f4910b716c872898796010 Mon Sep 17 00:00:00 2001
From: hect0x7 <93357912+hect0x7@users.noreply.github.com>
Date: Fri, 18 Jul 2025 00:13:44 +0800
Subject: [PATCH 3/4] =?UTF-8?q?v2.6.4:=20=E6=9C=AC=E5=AD=90=E8=AF=A6?=
=?UTF-8?q?=E6=83=85=E5=A2=9E=E5=8A=A0description=E5=AD=97=E6=AE=B5?=
=?UTF-8?q?=EF=BC=8Cimg2pdf=E6=8F=92=E4=BB=B6=E6=94=AF=E6=8C=81=E8=AE=BE?=
=?UTF-8?q?=E7=BD=AEpdf=E5=AF=86=E7=A0=81=20[skip=20ci]?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
assets/docs/sources/option_file_syntax.md | 2 ++
src/jmcomic/__init__.py | 2 +-
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/assets/docs/sources/option_file_syntax.md b/assets/docs/sources/option_file_syntax.md
index 00c9890b..f5e54342 100644
--- a/assets/docs/sources/option_file_syntax.md
+++ b/assets/docs/sources/option_file_syntax.md
@@ -279,6 +279,8 @@ plugins:
kwargs:
pdf_dir: D:/pdf/ # pdf存放文件夹
filename_rule: Pid # pdf命名规则,P代表photo, id代表使用photo.id也就是章节id
+ encrypt: # pdf密码,可选配置项
+ password: 123 # 密码
# img2pdf也支持合并整个本子,把上方的after_photo改为after_album即可。
# https://github.com/hect0x7/JMComic-Crawler-Python/discussions/258
diff --git a/src/jmcomic/__init__.py b/src/jmcomic/__init__.py
index ff525832..0dd7ba83 100644
--- a/src/jmcomic/__init__.py
+++ b/src/jmcomic/__init__.py
@@ -2,7 +2,7 @@
# 被依赖方 <--- 使用方
# config <--- entity <--- toolkit <--- client <--- option <--- downloader
-__version__ = '2.6.3'
+__version__ = '2.6.4'
from .api import *
from .jm_plugin import *
From 039b9cc89a16eb817ea252e0040f491fba45945c Mon Sep 17 00:00:00 2001
From: hect0x7 <93357912+hect0x7@users.noreply.github.com>
Date: Fri, 18 Jul 2025 00:14:41 +0800
Subject: [PATCH 4/4] [skip ci]
---
src/jmcomic/jm_plugin.py | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/src/jmcomic/jm_plugin.py b/src/jmcomic/jm_plugin.py
index a1726ddc..cbd17e1e 100644
--- a/src/jmcomic/jm_plugin.py
+++ b/src/jmcomic/jm_plugin.py
@@ -129,8 +129,7 @@ def decide_filepath(self,
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))
+ 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