Skip to content

Commit a348800

Browse files
committed
feat: add filename_show_password option for v2.6.3
1 parent a1ffafb commit a348800

14 files changed

Lines changed: 528 additions & 31 deletions

File tree

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@
22

33
所有版本更新记录。
44

5+
## **v2.6.3** (2026-01-05)
6+
7+
### 新增功能
8+
- **文件名显示密码** - 新增 `filename_show_password` 配置项
9+
- 开启后,打包文件名中会包含密码信息,便于用户识别
10+
- 默认关闭,保持原有命名方式
11+
12+
### 文档
13+
- README 新增 webp 图片格式说明
14+
15+
---
16+
517
## **v2.6.2** (2026-01-04)
618

719
### Bug 修复

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
<br>
1212
<div align="center">
13-
<a href="CHANGELOG.md"><img src="https://img.shields.io/badge/VERSION-v2.6.2-E91E63?style=for-the-badge" alt="Version"></a>
13+
<a href="CHANGELOG.md"><img src="https://img.shields.io/badge/VERSION-v2.6.3-E91E63?style=for-the-badge" alt="Version"></a>
1414
<a href="https://github.com/GEMILUXVII/astrbot_plugin_jm_cosmos/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-AGPL--3.0-009688?style=for-the-badge" alt="License"></a>
1515
<a href="https://www.python.org/"><img src="https://img.shields.io/badge/PYTHON-3.10+-3776AB?style=for-the-badge&logo=python&logoColor=white" alt="Python"></a>
1616
<a href="https://github.com/AstrBotDevs/AstrBot"><img src="https://img.shields.io/badge/AstrBot-Compatible-00BFA5?style=for-the-badge&logo=robot&logoColor=white" alt="AstrBot Compatible"></a>
@@ -19,7 +19,7 @@
1919
<div align="center">
2020
<a href="https://pypi.org/project/jmcomic/"><img src="https://img.shields.io/badge/JMCOMIC-≥2.5.0-9C27B0?style=for-the-badge" alt="JMComic"></a>
2121
<a href="https://github.com/botuniverse/onebot-11"><img src="https://img.shields.io/badge/OneBotv11-AIOCQHTTP-FF5722?style=for-the-badge&logo=qq&logoColor=white" alt="OneBot v11 Support"></a>
22-
<a href="https://github.com/GEMILUXVII/astrbot_plugin_jm_cosmos"><img src="https://img.shields.io/badge/UPDATED-2026.01.04-2196F3?style=for-the-badge" alt="Updated"></a>
22+
<a href="https://github.com/GEMILUXVII/astrbot_plugin_jm_cosmos"><img src="https://img.shields.io/badge/UPDATED-2026.01.05-2196F3?style=for-the-badge" alt="Updated"></a>
2323
</div>
2424

2525
## 介绍
@@ -261,6 +261,11 @@ pip install -r requirements.txt
261261
| `jm_username` | JM账号用户名 | 空(可选) |
262262
| `jm_password` | JM账号密码 | 空(可选) |
263263

264+
> [!NOTE]
265+
> **关于 webp 图片格式**
266+
>
267+
> `image_suffix` 设置为 `.webp` 时,**仅支持 ZIP 打包**。由于 pymupdf 库不支持 webp 格式,使用 PDF 打包将无法正常输出文件。webp 格式的优势在于体积更小,适合追求轻量化的用户;如无特殊需求,建议使用默认的 `.jpg` 格式以获得最佳兼容性。
268+
264269
> [!TIP]
265270
> **防风控建议**
266271
>
@@ -375,7 +380,7 @@ proxy_url: http://127.0.0.1:7890
375380

376381
查看完整更新日志:[CHANGELOG.md](./CHANGELOG.md)
377382

378-
**当前版本:v2.6.2** - 修复 Docker 环境代理问题 (Issue #43)
383+
**当前版本:v2.6.3** - 新增文件名显示密码配置项
379384

380385
## 注意事项
381386

_conf_schema.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@
6767
"hint": "为ZIP或PDF设置密码,留空则不加密",
6868
"default": ""
6969
},
70+
"filename_show_password": {
71+
"type": "bool",
72+
"description": "文件名显示密码",
73+
"hint": "开启后在文件名末尾添加 #PWxxx 提示(仅当设置了密码时生效)",
74+
"default": false
75+
},
7076
"auto_delete_after_send": {
7177
"type": "bool",
7278
"description": "发送后自动删除",

core/base/config.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ def pack_password(self) -> str:
8181
"""打包密码"""
8282
return self.plugin_config.get("pack_password", "")
8383

84+
@property
85+
def filename_show_password(self) -> bool:
86+
"""是否在文件名中显示密码提示"""
87+
return self.plugin_config.get("filename_show_password", False)
88+
8489
@property
8590
def auto_delete_after_send(self) -> bool:
8691
"""发送后是否自动删除"""

main.py

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
支持搜索、下载禁漫天堂的漫画本子,基于jmcomic库
55
"""
66

7-
import time
87
from pathlib import Path
98

109
import astrbot.api.message_components as Comp
@@ -13,7 +12,7 @@
1312
from astrbot.api.star import Context, Star, StarTools, register
1413

1514
from .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
# 插件名称常量
1918
PLUGIN_NAME = "jm_cosmos2"
@@ -23,7 +22,7 @@
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
)
2928
class 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)

metadata.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: JM-Cosmos II
22
desc: JM漫画下载插件 - 支持搜索、下载禁漫天堂的漫画本子,基于jmcomic库,支持加密PDF/ZIP打包
3-
version: v2.6.2
3+
version: v2.6.3
44
author: GEMILUXVII
55
repo: https://github.com/GEMILUXVII/astrbot_plugin_jm_cosmos

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
2-
name = "JM-Cosmos II"
3-
version = "2.5.5"
2+
name = "jm-cosmos-ii"
3+
version = "2.6.3"
44
description = "JM漫画下载插件 - 支持搜索、下载禁漫天堂的漫画本子,基于jmcomic库"
55
readme = "README.md"
66
requires-python = ">=3.10"

tests/integration/test_browse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ async def test_get_album_detail(self, browser, test_album_id):
100100
@pytest.mark.asyncio
101101
async def test_get_album_detail_invalid_id(self, browser):
102102
"""测试无效 ID"""
103-
detail = await browser.get_album_detail("999999999")
103+
_detail = await browser.get_album_detail("999999999")
104104

105105
# 无效 ID 应该返回 None 或抛出异常
106106
# 这里只验证不会崩溃

tests/integration/test_packer.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,11 @@
1515

1616
# 直接检测库是否可用,不依赖 packer 模块的常量
1717
def is_pyzipper_available():
18-
try:
19-
import pyzipper
20-
return True
21-
except ImportError:
22-
return False
18+
return importlib.util.find_spec("pyzipper") is not None
2319

2420

2521
def is_pymupdf_available():
26-
try:
27-
import fitz
28-
return True
29-
except ImportError:
30-
return False
22+
return importlib.util.find_spec("fitz") is not None
3123

3224

3325
class TestZipPackingIntegration:

tests/unit/conftest.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
提供测试所需的公共配置、临时目录和 mock 对象。
55
"""
66

7+
import importlib.util
78
import sys
9+
import types
810
from pathlib import Path
911
from typing import Any
1012
from unittest.mock import MagicMock, patch
@@ -23,7 +25,6 @@
2325
mock_jmcomic.JmcomicText = MagicMock()
2426

2527
# 设置 __spec__ 以通过 importlib.util.find_spec 检查
26-
import importlib.util
2728

2829
mock_spec = importlib.util.spec_from_loader("jmcomic", loader=None)
2930
mock_jmcomic.__spec__ = mock_spec
@@ -45,7 +46,6 @@
4546

4647
# 设置包层级结构以支持相对导入
4748
# 创建一个虚拟的顶级包来容纳 core 和 utils
48-
import types
4949

5050
# 创建顶级虚拟包
5151
plugin_pkg = types.ModuleType("astrbot_plugin_jm_cosmos")
@@ -54,8 +54,8 @@
5454
sys.modules["astrbot_plugin_jm_cosmos"] = plugin_pkg
5555

5656
# 预先导入核心模块并注册
57-
from core import base as core_base
58-
from core import constants as core_constants
57+
from core import base as core_base # noqa: E402
58+
from core import constants as core_constants # noqa: E402
5959

6060
# 设置 core 子包
6161
core_pkg = types.ModuleType("astrbot_plugin_jm_cosmos.core")

0 commit comments

Comments
 (0)