Skip to content

Commit 89419f8

Browse files
committed
v2.5.36: 修复保存gif图的bug,dir_rule配置支持python f-string语法
1 parent 521b500 commit 89419f8

4 files changed

Lines changed: 23 additions & 3 deletions

File tree

assets/docs/sources/option_file_syntax.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,14 @@ dir_rule:
9696
# 写法:
9797
# 1. 以'Bd'开头,表示根目录
9898
# 2. 文件夹每增加一层,使用 '_' 或者 '/' 区隔
99-
# 3. 用Pxxx或者Ayyy指代文件夹名,意思是 JmPhotoDetail.xxx / JmAlbumDetail的.yyy。xxx和yyy可以写什么需要看源码。
99+
# 3. 用Pxxx或者Ayyy指代文件夹名,意思是 JmPhotoDetail.xxx / JmAlbumDetail的.yyy。
100+
# xxx和yyy可以写什么需要看源码,或通过下面代码打印出所有可用的值
101+
#
102+
# ```python
103+
# import jmcomic
104+
# properties: dict = jmcomic.JmOption.default().new_jm_client().get_album_detail(本子id).get_properties_dict()
105+
# print(properties)
106+
# ```
100107
#
101108
# 下面演示如果要使用禁漫网站的默认下载方式,该怎么写:
102109
# 规则: 根目录 / 本子id / 章节序号 / 图片文件
@@ -105,6 +112,9 @@ dir_rule:
105112

106113
# 默认规则是: 根目录 / 章节标题 / 图片文件
107114
rule: Bd_Ptitle
115+
# jmcomic v2.5.36 以后,支持使用python的f-string的语法组合文件夹名,下为示例
116+
# rule: Bd / Aauthor / (JM{Aid}-{Pindex})-{Pname}
117+
# {}大括号里的内容同样是写 Axxx 或 Pxxx,其他语法自行参考python f-string的语法
108118
```
109119

110120
## 3. option插件配置项

src/jmcomic/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# 被依赖方 <--- 使用方
33
# config <--- entity <--- toolkit <--- client <--- option <--- downloader
44

5-
__version__ = '2.5.35'
5+
__version__ = '2.5.36'
66

77
from .api import *
88
from .jm_plugin import *

src/jmcomic/jm_client_interface.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,16 @@ def transfer_to(self,
6262
img_url=None,
6363
):
6464
img_url = img_url or self.url
65+
index = img_url.find("?")
66+
if index != -1:
67+
img_url = img_url[0:index]
6568

6669
if decode_image is False or scramble_id is None:
6770
# 不解密图片,直接保存文件
6871
JmImageTool.save_resp_img(
6972
self,
7073
path,
71-
need_convert=suffix_not_equal(img_url[:img_url.find("?")], path),
74+
need_convert=suffix_not_equal(img_url, path),
7275
)
7376
else:
7477
# 解密图片并保存文件

tests/test_jmcomic/test_jm_api.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,13 @@ def run_func_async(func):
7979

8080
def test_partial_exception(self):
8181
class TestDownloader(JmDownloader):
82+
def do_filter(self, detail: DetailEntity):
83+
if detail.is_photo():
84+
return detail[0:2]
85+
if detail.is_album():
86+
return detail[0:2]
87+
return super().do_filter(detail)
88+
8289
@catch_exception
8390
def download_by_image_detail(self, image: JmImageDetail):
8491
raise Exception('test_partial_exception')

0 commit comments

Comments
 (0)