From 6a63e9354d272915b5676436f244766449c918fc Mon Sep 17 00:00:00 2001 From: hect0x7 <93357912+hect0x7@users.noreply.github.com> Date: Sat, 30 Nov 2024 11:23:23 +0800 Subject: [PATCH] =?UTF-8?q?v2.5.25:=20=E6=94=AF=E6=8C=81Client=E7=9B=B4?= =?UTF-8?q?=E6=8E=A5=E4=B8=8B=E8=BD=BD=E6=97=A0=E6=B7=B7=E6=B7=86=E5=9B=BE?= =?UTF-8?q?=E7=89=87=EF=BC=8C=E6=B7=BB=E5=8A=A0docs=E7=A4=BA=E4=BE=8B=20(#?= =?UTF-8?q?312)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/docs/sources/tutorial/0_common_usage.md | 10 ++++++++-- src/jmcomic/__init__.py | 2 +- src/jmcomic/jm_client_interface.py | 5 +---- src/jmcomic/jm_toolkit.py | 2 +- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/assets/docs/sources/tutorial/0_common_usage.md b/assets/docs/sources/tutorial/0_common_usage.md index 8fa25c06..7bc5afb1 100644 --- a/assets/docs/sources/tutorial/0_common_usage.md +++ b/assets/docs/sources/tutorial/0_common_usage.md @@ -38,7 +38,7 @@ download_album(123, option) option.download_album(123) ``` -## 获取本子/章节/图片的实体类 +## 获取本子/章节/图片的实体类,下载图片 ```python from jmcomic import * @@ -59,7 +59,13 @@ def fetch(photo: JmPhotoDetail): image: JmImageDetail for image in photo: print(f'图片url: {image.img_url}') - + + # 下载单个图片 + client.download_by_image_detail(image, './a.jpg') + # 如果是已知未混淆的图片,也可以直接使用url来下载 + random_image_domain = JmModuleConfig.DOMAIN_IMAGE_LIST + client.download_image(f'https://{random_image_domain}/media/albums/416130.jpg', './a.jpg') + # 多线程发起请求 multi_thread_launcher( diff --git a/src/jmcomic/__init__.py b/src/jmcomic/__init__.py index 90979c1a..a46a31d8 100644 --- a/src/jmcomic/__init__.py +++ b/src/jmcomic/__init__.py @@ -2,7 +2,7 @@ # 被依赖方 <--- 使用方 # config <--- entity <--- toolkit <--- client <--- option <--- downloader -__version__ = '2.5.24' +__version__ = '2.5.25' from .api import * from .jm_plugin import * diff --git a/src/jmcomic/jm_client_interface.py b/src/jmcomic/jm_client_interface.py index 16f86aad..5ec98ea3 100644 --- a/src/jmcomic/jm_client_interface.py +++ b/src/jmcomic/jm_client_interface.py @@ -63,7 +63,7 @@ def transfer_to(self, ): img_url = img_url or self.url - if decode_image is False: + if decode_image is False or scramble_id is None: # 不解密图片,直接保存文件 JmImageTool.save_resp_img( self, @@ -245,9 +245,6 @@ def download_image(self, :param scramble_id: 图片所在photo的scramble_id :param decode_image: 要保存的是解密后的图还是原图 """ - if scramble_id is None: - scramble_id = JmMagicConstants.SCRAMBLE_220980 - # 请求图片 resp = self.get_jm_image(img_url) diff --git a/src/jmcomic/jm_toolkit.py b/src/jmcomic/jm_toolkit.py index 017f6752..0b2e531f 100644 --- a/src/jmcomic/jm_toolkit.py +++ b/src/jmcomic/jm_toolkit.py @@ -6,7 +6,7 @@ class JmcomicText: pattern_jm_domain = compile(r'https://([\w.-]+)') pattern_jm_pa_id = [ - (compile(r'(photos?|album)/(\d+)'), 2), + (compile(r'(photos?|albums?)/(\d+)'), 2), (compile(r'id=(\d+)'), 1), ] pattern_html_jm_pub_domain = compile(r'[\w-]+\.\w+/?\w+')