Skip to content

Commit 4f56f46

Browse files
authored
v2.4.10: 更新禁漫APP版本号(1.6.3->1.6.4) (#182)
1 parent dfd3fd6 commit 4f56f46

File tree

7 files changed

+30
-12
lines changed

7 files changed

+30
-12
lines changed

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.4.9'
5+
__version__ = '2.4.10'
66

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

src/jmcomic/jm_client_impl.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,14 @@ def setting(self) -> JmApiResp:
748748
}
749749
"""
750750
resp = self.req_api('/setting')
751+
752+
# 检查禁漫最新的版本号
753+
setting_ver = str(resp.model_data.version)
754+
# 禁漫接口的版本 > jmcomic库内置版本
755+
if setting_ver > JmMagicConstants.APP_VERSION and JmModuleConfig.flag_use_version_newer_if_behind:
756+
jm_log('api.setting', f'change APP_VERSION from [{JmMagicConstants.APP_VERSION}] to [{setting_ver}]')
757+
JmMagicConstants.APP_VERSION = setting_ver
758+
751759
return resp
752760

753761
def login(self,

src/jmcomic/jm_client_interface.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,8 @@ def get_html_domain_all(self, postman=None):
476476
# noinspection PyMethodMayBeStatic
477477
def do_page_iter(self, params: dict, page: int, get_page_method):
478478
from math import inf
479-
def update(value: Union[Dict], page: int, page_content: JmPageContent):
479+
480+
def update(value: Optional[Dict], page: int, page_content: JmPageContent):
480481
if value is None:
481482
return page + 1, page_content.page_count
482483

src/jmcomic/jm_config.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class JmMagicConstants:
6060
APP_TOKEN_SECRET = '18comicAPP'
6161
APP_TOKEN_SECRET_2 = '18comicAPPContent'
6262
APP_DATA_SECRET = '185Hcomic3PAPP7R'
63-
APP_VERSION = '1.6.3'
63+
APP_VERSION = '1.6.4'
6464
APP_HEADERS_TEMPLATE = {
6565
'Accept-Encoding': 'gzip',
6666
'user-agent': 'Mozilla/5.0 (Linux; Android 9; V1938CT Build/PQ3A.190705.09211555; wv) AppleWebKit/537.36 (KHTML, '
@@ -166,6 +166,8 @@ class JmModuleConfig:
166166
flag_enable_jm_log = True
167167
# log时解码url
168168
flag_decode_url_when_logging = True
169+
# 当内置的版本号落后时,使用最新的禁漫app版本号
170+
flag_use_version_newer_if_behind = False
169171

170172
# 关联dir_rule的自定义字段与对应的处理函数
171173
# 例如:
@@ -282,7 +284,7 @@ def new_html_headers(cls, domain='18comic.vip'):
282284
return headers
283285

284286
@classmethod
285-
@field_cache("__fix_ts_token_tokenparam__")
287+
@field_cache()
286288
def get_fix_ts_token_tokenparam(cls):
287289
ts = time_stamp()
288290
from .jm_toolkit import JmCryptoTool

src/jmcomic/jm_entity.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ def __init__(self, content, folder_list, total):
636636
def page_size(self) -> int:
637637
return JmMagicConstants.PAGE_SIZE_FAVORITE
638638

639-
def folder_id_name_iter(self) -> Generator[Tuple[str, str], None, None]:
639+
def iter_folder_id_name(self) -> Generator[Tuple[str, str], None, None]:
640640
"""
641641
用户文件夹的迭代器
642642
"""

src/jmcomic/jm_option.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,10 +253,10 @@ def decide_image_save_dir(self, photo) -> str:
253253
return save_dir
254254

255255
def decide_image_filepath(self, image: JmImageDetail, consider_custom_suffix=True) -> str:
256-
# 通过拼接生成绝对路径
256+
# 以此决定保存文件夹、后缀、不包含后缀的文件名
257257
save_dir = self.decide_image_save_dir(image.from_photo)
258258
suffix = self.decide_image_suffix(image) if consider_custom_suffix else image.img_file_suffix
259-
return os.path.join(save_dir, self.decide_image_filename(image) + suffix)
259+
return os.path.join(save_dir, fix_windir_name(self.decide_image_filename(image)) + suffix)
260260

261261
def decide_download_cache(self, _image: JmImageDetail) -> bool:
262262
return self.download.cache

src/jmcomic/jm_toolkit.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,6 @@ def parse_html_to_search_page(cls, html: str) -> JmSearchPage:
412412

413413
@classmethod
414414
def parse_html_to_category_page(cls, html: str) -> JmSearchPage:
415-
# 3. 提取结果
416415
content = []
417416
total = int(PatternTool.match_or_default(html, *cls.pattern_html_search_total))
418417

@@ -429,7 +428,6 @@ def parse_html_to_category_page(cls, html: str) -> JmSearchPage:
429428

430429
return JmSearchPage(content, total)
431430

432-
433431
@classmethod
434432
def parse_html_to_favorite_page(cls, html: str) -> JmFavoritePage:
435433
total = int(PatternTool.require_match(
@@ -893,8 +891,8 @@ class JmCryptoTool:
893891
@classmethod
894892
def token_and_tokenparam(cls,
895893
ts,
896-
ver=JmMagicConstants.APP_VERSION,
897-
secret=JmMagicConstants.APP_TOKEN_SECRET,
894+
ver=None,
895+
secret=None,
898896
):
899897
"""
900898
计算禁漫接口的请求headers的token和tokenparam
@@ -905,6 +903,12 @@ def token_and_tokenparam(cls,
905903
:return (token, tokenparam)
906904
"""
907905

906+
if ver is None:
907+
ver = JmMagicConstants.APP_VERSION
908+
909+
if secret is None:
910+
secret = JmMagicConstants.APP_TOKEN_SECRET
911+
908912
# tokenparam: 1700566805,1.6.3
909913
tokenparam = '{},{}'.format(ts, ver)
910914

@@ -917,7 +921,7 @@ def token_and_tokenparam(cls,
917921
def decode_resp_data(cls,
918922
data: str,
919923
ts,
920-
secret=JmMagicConstants.APP_DATA_SECRET,
924+
secret=None,
921925
) -> str:
922926
"""
923927
解密接口返回值
@@ -927,6 +931,9 @@ def decode_resp_data(cls,
927931
:param secret: 密钥
928932
:return: json格式的字符串
929933
"""
934+
if secret is None:
935+
secret = JmMagicConstants.APP_DATA_SECRET
936+
930937
# 1. base64解码
931938
import base64
932939
data_b64 = base64.b64decode(data)

0 commit comments

Comments
 (0)