44支持搜索、下载禁漫天堂的漫画本子,基于jmcomic库
55"""
66
7- import time
87from pathlib import Path
98
109import astrbot .api .message_components as Comp
1312from astrbot .api .star import Context , Star , StarTools , register
1413
1514from .core import JMAuthManager , JMBrowser , JMConfigManager , JMDownloadManager , JMPacker
16- from .utils import MessageFormatter , send_with_recall
15+ from .utils import MessageFormatter , generate_album_filename , send_with_recall
1716
1817# 插件名称常量
1918PLUGIN_NAME = "jm_cosmos2"
2322 "jm_cosmos2" ,
2423 "GEMILUXVII" ,
2524 "JM漫画下载插件 - 支持搜索、下载禁漫天堂的漫画本子,支持加密PDF/ZIP打包" ,
26- "2.6.2 " ,
25+ "2.6.3 " ,
2726 "https://github.com/GEMILUXVII/astrbot_plugin_jm_cosmos" ,
2827)
2928class JMCosmosPlugin (Star ):
@@ -122,7 +121,7 @@ async def download_album_command(
122121 # 发送开始下载提示
123122 yield event .plain_result (f"⏳ 开始下载本子 { album_id } ,请稍候..." )
124123
125- # 如果配置了发送封面预览,先获取详情和封面
124+ # 如果配置了发送封面预览,获取详情和封面
126125 if self .config_manager .send_cover_preview :
127126 detail = await self .browser .get_album_detail (album_id )
128127 if detail :
@@ -153,6 +152,13 @@ async def download_album_command(
153152 )
154153 return
155154
155+ # 生成文件名
156+ output_name = generate_album_filename (
157+ album_id = album_id ,
158+ password = self .config_manager .pack_password ,
159+ show_password = self .config_manager .filename_show_password ,
160+ )
161+
156162 # 打包文件
157163 packer = JMPacker (
158164 pack_format = self .config_manager .pack_format ,
@@ -161,7 +167,7 @@ async def download_album_command(
161167
162168 pack_result = packer .pack (
163169 source_dir = result .save_path ,
164- output_name = f"dl_ { album_id } _ { int ( time . time ()) } " ,
170+ output_name = output_name ,
165171 )
166172
167173 # 发送结果消息
@@ -259,6 +265,7 @@ async def download_photo_command(
259265 f"⏳ 正在获取本子 { album_id } 的第 { chapter_idx } 章节信息..."
260266 )
261267
268+
262269 # 获取章节的真正 photo_id
263270 chapter_info = await self .browser .get_photo_id_by_index (
264271 album_id , chapter_idx
@@ -291,6 +298,14 @@ async def download_photo_command(
291298 )
292299 return
293300
301+ # 生成文件名(带章节号)
302+ output_name = generate_album_filename (
303+ album_id = album_id ,
304+ password = self .config_manager .pack_password ,
305+ chapter_idx = chapter_idx ,
306+ show_password = self .config_manager .filename_show_password ,
307+ )
308+
294309 # 打包
295310 packer = JMPacker (
296311 pack_format = self .config_manager .pack_format ,
@@ -299,7 +314,7 @@ async def download_photo_command(
299314
300315 pack_result = packer .pack (
301316 source_dir = result .save_path ,
302- output_name = f"dl_ { album_id } _ch { chapter_idx } _ { int ( time . time ()) } " ,
317+ output_name = output_name ,
303318 )
304319
305320 result_msg = MessageFormatter .format_download_result (result , pack_result )
0 commit comments