Skip to content

Commit 18ba10e

Browse files
authored
v2.1.15: 修复scramble_id的默认值,优化缓存标志、debug-topic (#100)
1 parent 277bc6d commit 18ba10e

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

src/jmcomic/__init__.py

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

5-
__version__ = '2.1.14'
5+
__version__ = '2.1.15'
66

77
from .api import *

src/jmcomic/jm_client_impl.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def request_with_retry(self,
5757
api_path=url,
5858
domain=self.domain_list[domain_index],
5959
)
60-
jm_debug('api', url)
60+
jm_debug(self.debug_topic_request(), url)
6161
else:
6262
# 图片url
6363
pass
@@ -82,6 +82,10 @@ def request_with_retry(self,
8282
else:
8383
return self.request_with_retry(request, url, domain_index + 1, 0, **kwargs)
8484

85+
# noinspection PyMethodMayBeStatic
86+
def debug_topic_request(self):
87+
return 'html'
88+
8589
# noinspection PyMethodMayBeStatic, PyUnusedLocal
8690
def before_retry(self, e, kwargs, retry_count, url):
8791
jm_debug('req.err', str(e))
@@ -124,6 +128,11 @@ def wrap_func_cache(func_name, cache_dict_name):
124128
}:
125129
wrap_func_cache(func, func + '.cache.dict')
126130

131+
setattr(self, '__enable_cache__', True)
132+
133+
def is_cache_enabled(self) -> bool:
134+
return getattr(self, '__enable_cache__', False)
135+
127136
def get_jmcomic_url(self, postman=None):
128137
return JmModuleConfig.get_jmcomic_url(postman or self.get_root_postman())
129138

src/jmcomic/jm_client_interface.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,9 @@ def of_api_url(self, api_path, domain):
160160
def enable_cache(self, debug=False):
161161
raise NotImplementedError
162162

163+
def is_cache_enabled(self) -> bool:
164+
raise NotImplementedError
165+
163166
def check_photo(self, photo: JmPhotoDetail):
164167
"""
165168
photo来源有两种:
@@ -221,7 +224,7 @@ class JmImageClient:
221224
def download_image(self,
222225
img_url: str,
223226
img_save_path: str,
224-
scramble_id=None,
227+
scramble_id: Optional[int] = None,
225228
decode_image=True,
226229
):
227230
"""
@@ -232,8 +235,7 @@ def download_image(self,
232235
@param decode_image: 要保存的是解密后的图还是原图
233236
"""
234237
if scramble_id is None:
235-
# 大多数情况下,scramble_id = photo_id
236-
scramble_id = JmcomicText.parse_to_photo_id(scramble_id)
238+
scramble_id = JmModuleConfig.SCRAMBLE_0
237239

238240
# 请求图片
239241
resp = self.get_jm_image(img_url)
@@ -258,7 +260,7 @@ def download_by_image_detail(self,
258260
return self.download_image(
259261
image.download_url,
260262
img_save_path,
261-
image.scramble_id,
263+
int(image.scramble_id),
262264
decode_image=decode_image,
263265
)
264266

0 commit comments

Comments
 (0)