From 149356474d62b13c6b20980fb94fda6c60644833 Mon Sep 17 00:00:00 2001 From: hect0x7 <93357912+hect0x7@users.noreply.github.com> Date: Sun, 21 Dec 2025 21:58:32 +0800 Subject: [PATCH 1/8] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/jmcomic/jm_client_impl.py | 5 +---- src/jmcomic/jm_client_interface.py | 8 +++++++- src/jmcomic/jm_option.py | 5 +++-- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/jmcomic/jm_client_impl.py b/src/jmcomic/jm_client_impl.py index cd5f23b3..43ea6a1a 100644 --- a/src/jmcomic/jm_client_impl.py +++ b/src/jmcomic/jm_client_impl.py @@ -959,10 +959,7 @@ def require_resp_success(cls, resp: JmApiResp, url: Optional[str] = None): # 1. 检查是否 album_missing # json: {'code': 200, 'data': []} - data = resp.model().data - if isinstance(data, list) and len(data) == 0: - ExceptionTool.raise_missing(resp, JmcomicText.parse_to_jm_id(url)) - + # 最新api已不存在这种情况,无需检查 # 2. 是否是特殊的内容 # 暂无 diff --git a/src/jmcomic/jm_client_interface.py b/src/jmcomic/jm_client_interface.py index 22f8856d..8a6a1b10 100644 --- a/src/jmcomic/jm_client_interface.py +++ b/src/jmcomic/jm_client_interface.py @@ -122,18 +122,24 @@ def decoded_data(self) -> str: def encoded_data(self) -> str: return self.json()['data'] + def require_have_data(self): + data = self.encoded_data + if isinstance(data, list) and len(data) == 0 and self.json().get('errorMsg', None): + ExceptionTool.raises_resp(f'data返回值异常: {self.text}', self) + @property def res_data(self) -> Any: self.require_success() + self.require_have_data() from json import loads return loads(self.decoded_data) @property def model_data(self) -> AdvancedDict: self.require_success() + self.require_have_data() return AdvancedDict(self.res_data) - # album-comment class JmAlbumCommentResp(JmJsonResp): diff --git a/src/jmcomic/jm_option.py b/src/jmcomic/jm_option.py index 9c6ae612..643e10f2 100644 --- a/src/jmcomic/jm_option.py +++ b/src/jmcomic/jm_option.py @@ -1,4 +1,5 @@ from .jm_client_impl import * +from .jm_toolkit import JmcomicText class CacheRegistry: @@ -130,9 +131,9 @@ def parse_bd_rule(self, album, photo, rule): @classmethod def parse_f_string_rule(cls, album, photo, rule: str): properties = {} - if album: + if album is not None: properties.update(album.get_properties_dict()) - if photo: + if photo is not None: properties.update(photo.get_properties_dict()) return rule.format(**properties) From 70dd24f4fc273c1844757b73df5e82b7067c76cb Mon Sep 17 00:00:00 2001 From: hect0x7 <93357912+hect0x7@users.noreply.github.com> Date: Mon, 22 Dec 2025 14:52:34 +0800 Subject: [PATCH 2/8] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E7=A6=81=E6=BC=ABAPP=5FV?= =?UTF-8?q?ERSION=E5=AD=97=E6=AE=B5=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/jmcomic/jm_client_impl.py | 5 ++++- src/jmcomic/jm_toolkit.py | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/jmcomic/jm_client_impl.py b/src/jmcomic/jm_client_impl.py index 43ea6a1a..822f5fe8 100644 --- a/src/jmcomic/jm_client_impl.py +++ b/src/jmcomic/jm_client_impl.py @@ -813,7 +813,10 @@ def setting(self) -> JmApiResp: # 检查禁漫最新的版本号 setting_ver = str(resp.model_data.version) # 禁漫接口的版本 > jmcomic库内置版本 - if setting_ver > JmMagicConstants.APP_VERSION and JmModuleConfig.FLAG_USE_VERSION_NEWER_IF_BEHIND: + if ( + JmModuleConfig.FLAG_USE_VERSION_NEWER_IF_BEHIND + and JmcomicText.compare_versions(setting_ver, JmMagicConstants.APP_VERSION) == 1 + ): jm_log('api.setting', f'change APP_VERSION from [{JmMagicConstants.APP_VERSION}] to [{setting_ver}]') JmMagicConstants.APP_VERSION = setting_ver diff --git a/src/jmcomic/jm_toolkit.py b/src/jmcomic/jm_toolkit.py index c683e3c1..c859fdfa 100644 --- a/src/jmcomic/jm_toolkit.py +++ b/src/jmcomic/jm_toolkit.py @@ -414,6 +414,22 @@ def get_album_cover_url(cls, path = f'/media/albums/{cls.parse_to_jm_id(album_id)}{size}.jpg' return cls.format_url(path, image_domain) + @classmethod + def compare_versions(cls, v1: str, v2: str) -> int: + parts1 = list(map(int, v1.split("."))) + parts2 = list(map(int, v2.split("."))) + + # 补齐长度 + length = max(len(parts1), len(parts2)) + parts1 += [0] * (length - len(parts1)) + parts2 += [0] * (length - len(parts2)) + + if parts1 > parts2: + return 1 # v1 大 + elif parts1 < parts2: + return -1 # v2 大 + else: + return 0 # 相等 # 支持dsl: #{???} -> os.getenv(???) JmcomicText.dsl_replacer.add_dsl_and_replacer(r'\$\{(.*?)\}', JmcomicText.match_os_env) From 733b040d3b6ffc9db3dd98ed5638d19b9e80b216 Mon Sep 17 00:00:00 2001 From: hect0x7 <93357912+hect0x7@users.noreply.github.com> Date: Mon, 22 Dec 2025 14:58:59 +0800 Subject: [PATCH 3/8] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E7=A6=81=E6=BC=ABAPP=5FV?= =?UTF-8?q?ERSION=E5=AD=97=E6=AE=B5=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/jmcomic/jm_client_impl.py | 45 ++--------------------------------- src/jmcomic/jm_option.py | 1 - 2 files changed, 2 insertions(+), 44 deletions(-) diff --git a/src/jmcomic/jm_client_impl.py b/src/jmcomic/jm_client_impl.py index 822f5fe8..e4884fce 100644 --- a/src/jmcomic/jm_client_impl.py +++ b/src/jmcomic/jm_client_impl.py @@ -765,53 +765,12 @@ def fetch_photo_additional_field(self, photo: JmPhotoDetail, fetch_album: bool, def setting(self) -> JmApiResp: """ - 禁漫app的setting请求,返回如下内容(resp.res_data) - { - "logo_path": "https://cdn-msp.jmapiproxy1.monster/media/logo/new_logo.png", - "main_web_host": "18-comic.work", - "img_host": "https://cdn-msp.jmapiproxy1.monster", - "base_url": "https://www.jmapinode.biz", - "is_cn": 0, - "cn_base_url": "https://www.jmapinode.biz", - "version": "1.6.0", - "test_version": "1.6.1", - "store_link": "https://play.google.com/store/apps/details?id=com.jiaohua_browser", - "ios_version": "1.6.0", - "ios_test_version": "1.6.1", - "ios_store_link": "https://18comic.vip/stray/", - "ad_cache_version": 1698140798, - "bundle_url": "https://18-comic.work/static/apk/patches1.6.0.zip", - "is_hot_update": true, - "api_banner_path": "https://cdn-msp.jmapiproxy1.monster/media/logo/channel_log.png?v=", - "version_info": "\nAPP & IOS更新\nV1.6.0\n#禁漫 APK 更新拉!!\n更新調整以下項目\n1. 系統優化\n\nV1.5.9\n1. 跳錯誤新增 重試 網頁 按鈕\n2. 圖片讀取優化\n3. - 線路調整優化\n\n無法順利更新或是系統題是有風險請使用下方\n下載點2\n有問題可以到DC群反饋\nhttps://discord.gg/V74p7HM\n", - "app_shunts": [ - { - "title": "圖源1", - "key": 1 - }, - { - "title": "圖源2", - "key": 2 - }, - { - "title": "圖源3", - "key": 3 - }, - { - "title": "圖源4", - "key": 4 - } - ], - "download_url": "https://18-comic.work/static/apk/1.6.0.apk", - "app_landing_page": "https://jm365.work/pXYbfA", - "float_ad": true - } + 禁漫app的setting请求 """ resp = self.req_api('/setting') # 检查禁漫最新的版本号 - setting_ver = str(resp.model_data.version) + setting_ver = str(resp.model_data.jm3_version) # 禁漫接口的版本 > jmcomic库内置版本 if ( JmModuleConfig.FLAG_USE_VERSION_NEWER_IF_BEHIND diff --git a/src/jmcomic/jm_option.py b/src/jmcomic/jm_option.py index 643e10f2..c7e3c814 100644 --- a/src/jmcomic/jm_option.py +++ b/src/jmcomic/jm_option.py @@ -1,5 +1,4 @@ from .jm_client_impl import * -from .jm_toolkit import JmcomicText class CacheRegistry: From 56997e839c77d2b96f45b0b4d0c06b58add2dd44 Mon Sep 17 00:00:00 2001 From: hect0x7 <93357912+hect0x7@users.noreply.github.com> Date: Mon, 22 Dec 2025 15:02:32 +0800 Subject: [PATCH 4/8] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E7=A6=81=E6=BC=ABAPP=5FV?= =?UTF-8?q?ERSION=E5=AD=97=E6=AE=B5=E6=9B=B4=E6=96=B0=20[skip=20ci]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/jmcomic/jm_config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/jmcomic/jm_config.py b/src/jmcomic/jm_config.py index 8e733afc..898e7954 100644 --- a/src/jmcomic/jm_config.py +++ b/src/jmcomic/jm_config.py @@ -77,7 +77,7 @@ class JmMagicConstants: APP_TOKEN_SECRET_2 = '18comicAPPContent' APP_DATA_SECRET = '185Hcomic3PAPP7R' API_DOMAIN_SERVER_SECRET = 'diosfjckwpqpdfjkvnqQjsik' - APP_VERSION = '2.0.6' + APP_VERSION = '2.0.13' # 模块级别共用配置 From 73fe17ed425da22af30f522c77fe9b55676c8a86 Mon Sep 17 00:00:00 2001 From: hect0x7 <93357912+hect0x7@users.noreply.github.com> Date: Sun, 21 Dec 2025 22:18:59 +0800 Subject: [PATCH 5/8] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96API=E5=9F=9F?= =?UTF-8?q?=E5=90=8D=E6=9B=B4=E6=96=B0=E6=97=B6=E7=9A=84=E5=B9=B6=E5=8F=91?= =?UTF-8?q?=E6=8E=A7=E5=88=B6=E5=92=8C=E5=BC=82=E5=B8=B8=E5=A4=84=E7=90=86?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/jmcomic/jm_client_impl.py | 37 ++++++++++++++++++++++------------- src/jmcomic/jm_config.py | 3 ++- 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/src/jmcomic/jm_client_impl.py b/src/jmcomic/jm_client_impl.py index e4884fce..fa1a0bd3 100644 --- a/src/jmcomic/jm_client_impl.py +++ b/src/jmcomic/jm_client_impl.py @@ -966,7 +966,8 @@ def raise_if_resp_should_retry(self, resp, is_image): def after_init(self): # 自动更新禁漫API域名 if JmModuleConfig.FLAG_API_CLIENT_AUTO_UPDATE_DOMAIN: - self.update_api_domain() + new_server_list = self.fetch_latest_api_domain_for_module() + self.update_old_api_domain(new_server_list) # 保证拥有cookies,因为移动端要求必须携带cookies,否则会直接跳转同一本子【禁漫娘】 if JmModuleConfig.FLAG_API_CLIENT_REQUIRE_COOKIES: @@ -991,13 +992,19 @@ def req_api_domain_server(self, url): else: return res_data['Server'] - def update_api_domain(self): - if True is JmModuleConfig.FLAG_API_CLIENT_AUTO_UPDATE_DOMAIN_DONE: - return + def update_old_api_domain(self, new_server_list: list[str]): + if new_server_list and sorted(self.domain_list) == sorted(JmModuleConfig.DOMAIN_API_LIST): + self.domain_list = new_server_list + + def fetch_latest_api_domain_for_module(self): + if JmModuleConfig.DOMAIN_API_UPDATED_LIST is not None: + return JmModuleConfig.DOMAIN_API_UPDATED_LIST with self.client_update_domain_lock: - if True is JmModuleConfig.FLAG_API_CLIENT_AUTO_UPDATE_DOMAIN_DONE: - return + # double check + if JmModuleConfig.DOMAIN_API_UPDATED_LIST is not None: + return JmModuleConfig.DOMAIN_API_UPDATED_LIST + # 遍历多个域名服务器 for url in JmModuleConfig.API_URL_DOMAIN_SERVER_LIST: try: @@ -1009,18 +1016,20 @@ def update_api_domain(self): jm_log('api.update_domain.success', f'获取到最新的API域名,替换jmcomic内置域名:(new){new_server_list} ---→ (old){old_server_list}' ) - # 更新域名 - if sorted(self.domain_list) == sorted(old_server_list): - self.domain_list = new_server_list - JmModuleConfig.DOMAIN_API_LIST = new_server_list - break + JmModuleConfig.DOMAIN_API_UPDATED_LIST = new_server_list + return new_server_list except Exception as e: jm_log('api.update_domain.error', - f'通过[{url}]自动更新API域名失败,仍使用jmcomic内置域名。' + f'通过[{url}]自动更新API域名失败,尝试下一个地址。' f'可通过代码[JmModuleConfig.FLAG_API_CLIENT_AUTO_UPDATE_DOMAIN=False]关闭自动更新API域名. 异常: {e}' ) - # set done finally - JmModuleConfig.FLAG_API_CLIENT_AUTO_UPDATE_DOMAIN_DONE = True + continue + + # 走到这里,说明没有获取到域名更新 + # 为了本方法不被重复执行,把新域名字段修改为空列表 + # 空列表相当于一个done标识 + JmModuleConfig.DOMAIN_API_UPDATED_LIST = [] + return JmModuleConfig.DOMAIN_API_UPDATED_LIST client_init_cookies_lock = Lock() diff --git a/src/jmcomic/jm_config.py b/src/jmcomic/jm_config.py index 898e7954..e16637a6 100644 --- a/src/jmcomic/jm_config.py +++ b/src/jmcomic/jm_config.py @@ -134,6 +134,8 @@ class JmModuleConfig: www.cdnplaystation6.cc ''') + DOMAIN_API_UPDATED_LIST = None + # 获取最新移动端API域名的地址 API_URL_DOMAIN_SERVER_LIST = shuffled(''' https://rup4a04-c01.tos-ap-southeast-1.bytepluses.com/newsvr-2025.txt @@ -209,7 +211,6 @@ class JmModuleConfig: FLAG_API_CLIENT_REQUIRE_COOKIES = True # 自动更新禁漫API域名 FLAG_API_CLIENT_AUTO_UPDATE_DOMAIN = True - FLAG_API_CLIENT_AUTO_UPDATE_DOMAIN_DONE = None # log开关标记 FLAG_ENABLE_JM_LOG = True # log时解码url From 8df9bb2a070fb1837a2cfe96f1b189895b21238f Mon Sep 17 00:00:00 2001 From: hect0x7 <93357912+hect0x7@users.noreply.github.com> Date: Thu, 8 Jan 2026 21:37:25 +0800 Subject: [PATCH 6/8] fix tests --- tests/test_jmcomic/test_jm_custom.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_jmcomic/test_jm_custom.py b/tests/test_jmcomic/test_jm_custom.py index a61354a5..1bbb222c 100644 --- a/tests/test_jmcomic/test_jm_custom.py +++ b/tests/test_jmcomic/test_jm_custom.py @@ -44,8 +44,8 @@ class MyClient(JmApiClient): JmModuleConfig.register_client(MyClient) self.assertListEqual( - JmModuleConfig.DOMAIN_API_LIST, - self.option.new_jm_client(domain_list=[], impl=MyClient.client_key).get_domain_list() + self.option.new_jm_client(domain_list=[], impl=MyClient.client_key).get_domain_list(), + JmModuleConfig.DOMAIN_API_UPDATED_LIST if JmModuleConfig.DOMAIN_API_UPDATED_LIST else JmModuleConfig.DOMAIN_API_LIST, ) def test_extends_html_client(self): @@ -104,7 +104,7 @@ class MyClient(JmApiClient): JmModuleConfig.register_client(MyClient) self.assertListEqual( - JmModuleConfig.DOMAIN_API_LIST, self.option.new_jm_client(domain_list=[], impl=MyClient.client_key).get_domain_list(), + JmModuleConfig.DOMAIN_API_UPDATED_LIST if JmModuleConfig.DOMAIN_API_UPDATED_LIST else JmModuleConfig.DOMAIN_API_LIST, msg='继承client,不配置域名', ) From 29ee70d639dc6b8a79d2b5c29bcb003d60cadfd7 Mon Sep 17 00:00:00 2001 From: hect0x7 <93357912+hect0x7@users.noreply.github.com> Date: Thu, 8 Jan 2026 21:39:23 +0800 Subject: [PATCH 7/8] typing --- src/jmcomic/jm_client_impl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/jmcomic/jm_client_impl.py b/src/jmcomic/jm_client_impl.py index fa1a0bd3..d98fa98b 100644 --- a/src/jmcomic/jm_client_impl.py +++ b/src/jmcomic/jm_client_impl.py @@ -992,7 +992,7 @@ def req_api_domain_server(self, url): else: return res_data['Server'] - def update_old_api_domain(self, new_server_list: list[str]): + def update_old_api_domain(self, new_server_list: List[str]): if new_server_list and sorted(self.domain_list) == sorted(JmModuleConfig.DOMAIN_API_LIST): self.domain_list = new_server_list From 2018e4141c56ed00cf0c1865c037eb7754af5d0a Mon Sep 17 00:00:00 2001 From: hect0x7 <93357912+hect0x7@users.noreply.github.com> Date: Thu, 8 Jan 2026 21:41:16 +0800 Subject: [PATCH 8/8] =?UTF-8?q?v2.6.11:=20=E4=BF=AE=E6=AD=A3APP=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E5=8F=B7=E3=80=81=E5=9F=9F=E5=90=8D=E7=9A=84=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E6=9B=B4=E6=96=B0=E9=80=BB=E8=BE=91=20[skip=20ci]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/jmcomic/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/jmcomic/__init__.py b/src/jmcomic/__init__.py index fd82ee2a..8a97b318 100644 --- a/src/jmcomic/__init__.py +++ b/src/jmcomic/__init__.py @@ -2,7 +2,7 @@ # 被依赖方 <--- 使用方 # config <--- entity <--- toolkit <--- client <--- option <--- downloader -__version__ = '2.6.10' +__version__ = '2.6.11' from .api import * from .jm_plugin import *