jmcomic 2.7.4__tar.gz → 2.7.6__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {jmcomic-2.7.4/src/jmcomic.egg-info → jmcomic-2.7.6}/PKG-INFO +5 -4
- {jmcomic-2.7.4 → jmcomic-2.7.6}/README.md +4 -3
- {jmcomic-2.7.4 → jmcomic-2.7.6}/src/jmcomic/__init__.py +1 -1
- {jmcomic-2.7.4 → jmcomic-2.7.6}/src/jmcomic/jm_async_client.py +55 -12
- {jmcomic-2.7.4 → jmcomic-2.7.6}/src/jmcomic/jm_client_impl.py +92 -21
- {jmcomic-2.7.4 → jmcomic-2.7.6}/src/jmcomic/jm_client_interface.py +17 -5
- {jmcomic-2.7.4 → jmcomic-2.7.6}/src/jmcomic/jm_config.py +5 -1
- {jmcomic-2.7.4 → jmcomic-2.7.6}/src/jmcomic/jm_exception.py +23 -0
- {jmcomic-2.7.4 → jmcomic-2.7.6}/src/jmcomic/jm_plugin.py +10 -1
- {jmcomic-2.7.4 → jmcomic-2.7.6}/src/jmcomic/jm_toolkit.py +5 -2
- {jmcomic-2.7.4 → jmcomic-2.7.6/src/jmcomic.egg-info}/PKG-INFO +5 -4
- {jmcomic-2.7.4 → jmcomic-2.7.6}/LICENSE +0 -0
- {jmcomic-2.7.4 → jmcomic-2.7.6}/pyproject.toml +0 -0
- {jmcomic-2.7.4 → jmcomic-2.7.6}/setup.cfg +0 -0
- {jmcomic-2.7.4 → jmcomic-2.7.6}/setup.py +0 -0
- {jmcomic-2.7.4 → jmcomic-2.7.6}/src/jmcomic/api.py +0 -0
- {jmcomic-2.7.4 → jmcomic-2.7.6}/src/jmcomic/cli.py +0 -0
- {jmcomic-2.7.4 → jmcomic-2.7.6}/src/jmcomic/jm_async_downloader.py +0 -0
- {jmcomic-2.7.4 → jmcomic-2.7.6}/src/jmcomic/jm_downloader.py +0 -0
- {jmcomic-2.7.4 → jmcomic-2.7.6}/src/jmcomic/jm_entity.py +0 -0
- {jmcomic-2.7.4 → jmcomic-2.7.6}/src/jmcomic/jm_feature.py +0 -0
- {jmcomic-2.7.4 → jmcomic-2.7.6}/src/jmcomic/jm_option.py +0 -0
- {jmcomic-2.7.4 → jmcomic-2.7.6}/src/jmcomic/jm_task_context.py +0 -0
- {jmcomic-2.7.4 → jmcomic-2.7.6}/src/jmcomic.egg-info/SOURCES.txt +0 -0
- {jmcomic-2.7.4 → jmcomic-2.7.6}/src/jmcomic.egg-info/dependency_links.txt +0 -0
- {jmcomic-2.7.4 → jmcomic-2.7.6}/src/jmcomic.egg-info/entry_points.txt +0 -0
- {jmcomic-2.7.4 → jmcomic-2.7.6}/src/jmcomic.egg-info/requires.txt +0 -0
- {jmcomic-2.7.4 → jmcomic-2.7.6}/src/jmcomic.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: jmcomic
|
|
3
|
-
Version: 2.7.
|
|
3
|
+
Version: 2.7.6
|
|
4
4
|
Summary: Python API For JMComic (禁漫天堂)
|
|
5
5
|
Home-page: https://github.com/hect0x7/JMComic-Crawler-Python
|
|
6
6
|
Author: hect0x7
|
|
@@ -120,7 +120,7 @@ Dynamic: requires-python
|
|
|
120
120
|
## 安装教程
|
|
121
121
|
|
|
122
122
|
> ⚠如果你没有安装过 Python,需要先前往 [Python 官网下载](https://www.python.org/downloads/) 再执行以下步骤。
|
|
123
|
-
>**推荐使用 Python 3.
|
|
123
|
+
>**推荐使用 Python 3.14**
|
|
124
124
|
|
|
125
125
|
* 通过pip官方源安装(推荐,并且更新也是这个命令)
|
|
126
126
|
|
|
@@ -312,8 +312,9 @@ jmv 350234 -y
|
|
|
312
312
|
|
|
313
313
|
## 使用小说明
|
|
314
314
|
|
|
315
|
-
* 推荐使用 **Python 3.
|
|
316
|
-
>
|
|
315
|
+
* 推荐使用 **Python 3.14**,目前 CI 只覆盖 Python 3.10 及以上版本。
|
|
316
|
+
> [!NOTE]
|
|
317
|
+
> Python 3.9 及更早版本均已结束官方支持 (EOL),使用3.9及以下随时有可能遇到第三方库不兼容的问题。Python 3.9 仍保留安装兼容,但不再纳入 CI。
|
|
317
318
|
|
|
318
319
|
* 个人项目,文档和示例会有不及时之处,可以Issue提问。
|
|
319
320
|
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
## 安装教程
|
|
64
64
|
|
|
65
65
|
> ⚠如果你没有安装过 Python,需要先前往 [Python 官网下载](https://www.python.org/downloads/) 再执行以下步骤。
|
|
66
|
-
>**推荐使用 Python 3.
|
|
66
|
+
>**推荐使用 Python 3.14**
|
|
67
67
|
|
|
68
68
|
* 通过pip官方源安装(推荐,并且更新也是这个命令)
|
|
69
69
|
|
|
@@ -255,8 +255,9 @@ jmv 350234 -y
|
|
|
255
255
|
|
|
256
256
|
## 使用小说明
|
|
257
257
|
|
|
258
|
-
* 推荐使用 **Python 3.
|
|
259
|
-
>
|
|
258
|
+
* 推荐使用 **Python 3.14**,目前 CI 只覆盖 Python 3.10 及以上版本。
|
|
259
|
+
> [!NOTE]
|
|
260
|
+
> Python 3.9 及更早版本均已结束官方支持 (EOL),使用3.9及以下随时有可能遇到第三方库不兼容的问题。Python 3.9 仍保留安装兼容,但不再纳入 CI。
|
|
260
261
|
|
|
261
262
|
* 个人项目,文档和示例会有不及时之处,可以Issue提问。
|
|
262
263
|
|
|
@@ -35,7 +35,7 @@ class AsyncJmApiClient(AsyncJmcomicClient):
|
|
|
35
35
|
禁漫移动端异步 API 客户端。
|
|
36
36
|
|
|
37
37
|
继承 AsyncJmcomicClient 接口,提供全面的异步网络通信能力,
|
|
38
|
-
|
|
38
|
+
涵盖本子、章节、搜索、登录与收藏夹等功能模块。
|
|
39
39
|
通过异步会话管理与并发请求调度,显著提升网络 I/O 的处理性能与吞吐量。
|
|
40
40
|
"""
|
|
41
41
|
|
|
@@ -260,6 +260,7 @@ class AsyncJmApiClient(AsyncJmcomicClient):
|
|
|
260
260
|
if not domain_list:
|
|
261
261
|
ExceptionTool.raises("无可用 API 域名列表")
|
|
262
262
|
|
|
263
|
+
retry_errors = []
|
|
263
264
|
for domain_index, domain in enumerate(domain_list):
|
|
264
265
|
url = self._build_api_url(url_path, domain)
|
|
265
266
|
|
|
@@ -289,11 +290,21 @@ class AsyncJmApiClient(AsyncJmcomicClient):
|
|
|
289
290
|
return resp
|
|
290
291
|
except Exception as e:
|
|
291
292
|
self.before_retry(e, url, retry, domain_index)
|
|
293
|
+
retry_errors.append({
|
|
294
|
+
'domain': domain,
|
|
295
|
+
'url': url,
|
|
296
|
+
'retry': retry,
|
|
297
|
+
'error': e,
|
|
298
|
+
})
|
|
292
299
|
|
|
293
300
|
# 所有域名都失败
|
|
294
301
|
msg = f"请求重试全部失败: [{url_path}], {domain_list}"
|
|
295
302
|
jm_log('req.fallback', msg)
|
|
296
|
-
ExceptionTool.raises(
|
|
303
|
+
ExceptionTool.raises(
|
|
304
|
+
msg,
|
|
305
|
+
{ExceptionTool.CONTEXT_KEY_RETRY_ERRORS: retry_errors},
|
|
306
|
+
RequestRetryAllFailException,
|
|
307
|
+
)
|
|
297
308
|
|
|
298
309
|
# noinspection PyMethodMayBeStatic,PyUnusedLocal
|
|
299
310
|
def before_retry(self, e, url, retry, domain_index):
|
|
@@ -406,7 +417,7 @@ class AsyncJmApiClient(AsyncJmcomicClient):
|
|
|
406
417
|
return result
|
|
407
418
|
|
|
408
419
|
async def get_album_detail(self, album_id) -> JmAlbumDetail:
|
|
409
|
-
"""
|
|
420
|
+
"""获取本子详情信息"""
|
|
410
421
|
return await self._fetch_detail_entity(album_id, JmModuleConfig.album_class())
|
|
411
422
|
|
|
412
423
|
async def get_photo_detail(self,
|
|
@@ -423,7 +434,7 @@ class AsyncJmApiClient(AsyncJmcomicClient):
|
|
|
423
434
|
async def _fetch_photo_additional_field(self, photo: JmPhotoDetail,
|
|
424
435
|
fetch_album: bool,
|
|
425
436
|
fetch_scramble_id: bool):
|
|
426
|
-
"""
|
|
437
|
+
"""并发获取图片从属的本子信息与 scramble_id 加解密参数。"""
|
|
427
438
|
tasks = {}
|
|
428
439
|
if fetch_album:
|
|
429
440
|
tasks['album'] = self.get_album_detail(photo.album_id)
|
|
@@ -581,7 +592,7 @@ class AsyncJmApiClient(AsyncJmcomicClient):
|
|
|
581
592
|
sub_category: str | None = None,
|
|
582
593
|
) -> JmCategoryPage:
|
|
583
594
|
"""
|
|
584
|
-
|
|
595
|
+
获取指定分类下的本子列表数据。
|
|
585
596
|
注意:移动端不支持 sub_category。
|
|
586
597
|
"""
|
|
587
598
|
o = f'{order_by}_{time}' if time != JmMagicConstants.TIME_ALL else order_by
|
|
@@ -618,11 +629,11 @@ class AsyncJmApiClient(AsyncJmcomicClient):
|
|
|
618
629
|
|
|
619
630
|
async def favorite_folder(self,
|
|
620
631
|
page=1,
|
|
621
|
-
order_by=JmMagicConstants.
|
|
632
|
+
order_by=JmMagicConstants.ORDER_FF_FAVORITE_TIME,
|
|
622
633
|
folder_id='0',
|
|
623
634
|
username='',
|
|
624
635
|
) -> JmFavoritePage:
|
|
625
|
-
"""
|
|
636
|
+
"""获取收藏夹内特定目录的本子数据分页。"""
|
|
626
637
|
resp = await self.req_api(
|
|
627
638
|
self.API_FAVORITE,
|
|
628
639
|
params={
|
|
@@ -665,18 +676,50 @@ class AsyncJmApiClient(AsyncJmcomicClient):
|
|
|
665
676
|
)
|
|
666
677
|
return JmPageTool.parse_api_to_album_comment_page(resp.model_data, page)
|
|
667
678
|
|
|
668
|
-
async def
|
|
679
|
+
async def toggle_favorite_album(self,
|
|
680
|
+
album_id,
|
|
681
|
+
folder_id='0',
|
|
682
|
+
expected_type: Optional[str] = None,
|
|
683
|
+
):
|
|
669
684
|
"""
|
|
670
|
-
|
|
671
|
-
|
|
685
|
+
切换本子的收藏状态(移动端接口底层为 Toggle 逻辑)。
|
|
686
|
+
:param album_id: 本子ID
|
|
687
|
+
:param folder_id: 移动端没有提供 folder_id 参数,保留参数兼容
|
|
688
|
+
:param expected_type: 期望的操作类型 ('add' | 'remove'),如果不匹配则抛异常
|
|
672
689
|
"""
|
|
673
|
-
|
|
674
|
-
|
|
690
|
+
resp = await self.req_api(
|
|
691
|
+
self.API_FAVORITE,
|
|
692
|
+
get=False,
|
|
693
|
+
data={'aid': album_id},
|
|
694
|
+
)
|
|
675
695
|
data = resp.model_data
|
|
676
696
|
if data.status != 'ok':
|
|
677
697
|
ExceptionTool.raises_resp(data.msg, resp)
|
|
698
|
+
|
|
699
|
+
if expected_type is not None:
|
|
700
|
+
actual_type = data.type
|
|
701
|
+
if actual_type != expected_type:
|
|
702
|
+
ExceptionTool.raises_resp(
|
|
703
|
+
f'收藏操作不符合预期,期望 [{expected_type}],实际为 [{actual_type}]: {data.msg}',
|
|
704
|
+
resp
|
|
705
|
+
)
|
|
706
|
+
|
|
678
707
|
return resp
|
|
679
708
|
|
|
709
|
+
async def add_favorite_album(self, album_id, folder_id='0'):
|
|
710
|
+
"""
|
|
711
|
+
将指定本子加入用户的收藏夹。
|
|
712
|
+
如果当前已收藏,将抛出异常以保证收藏语义明确。
|
|
713
|
+
"""
|
|
714
|
+
return await self.toggle_favorite_album(album_id, folder_id, expected_type='add')
|
|
715
|
+
|
|
716
|
+
async def delete_favorite_album(self, album_id, folder_id='0'):
|
|
717
|
+
"""
|
|
718
|
+
将指定本子移出用户的收藏夹。
|
|
719
|
+
如果当前未收藏,将抛出异常以保证取消收藏语义明确。
|
|
720
|
+
"""
|
|
721
|
+
return await self.toggle_favorite_album(album_id, folder_id, expected_type='remove')
|
|
722
|
+
|
|
680
723
|
async def album_comment(self,
|
|
681
724
|
video_id,
|
|
682
725
|
comment,
|
|
@@ -2,7 +2,6 @@ from copy import deepcopy
|
|
|
2
2
|
from threading import Lock
|
|
3
3
|
|
|
4
4
|
from .jm_task_context import bind_jm_task_context
|
|
5
|
-
|
|
6
5
|
from .jm_client_interface import *
|
|
7
6
|
|
|
8
7
|
|
|
@@ -59,6 +58,7 @@ class AbstractJmClient(
|
|
|
59
58
|
domain_index=0,
|
|
60
59
|
retry_count=0,
|
|
61
60
|
is_image=False,
|
|
61
|
+
_retry_errors=None,
|
|
62
62
|
**kwargs,
|
|
63
63
|
):
|
|
64
64
|
"""
|
|
@@ -83,8 +83,12 @@ class AbstractJmClient(
|
|
|
83
83
|
**kwargs,
|
|
84
84
|
)
|
|
85
85
|
|
|
86
|
+
if _retry_errors is None:
|
|
87
|
+
_retry_errors = []
|
|
88
|
+
|
|
86
89
|
if domain_index >= len(self.domain_list):
|
|
87
|
-
return self.fallback(request, url, domain_index, retry_count, is_image,
|
|
90
|
+
return self.fallback(request, url, domain_index, retry_count, is_image,
|
|
91
|
+
retry_errors=_retry_errors, **kwargs)
|
|
88
92
|
|
|
89
93
|
url_backup = url
|
|
90
94
|
|
|
@@ -120,11 +124,19 @@ class AbstractJmClient(
|
|
|
120
124
|
raise e
|
|
121
125
|
|
|
122
126
|
self.before_retry(e, kwargs, retry_count, url)
|
|
127
|
+
_retry_errors.append({
|
|
128
|
+
'domain': self.domain_list[domain_index] if url_backup.startswith('/') else None,
|
|
129
|
+
'url': url,
|
|
130
|
+
'retry': retry_count,
|
|
131
|
+
'error': e,
|
|
132
|
+
})
|
|
123
133
|
|
|
124
134
|
if retry_count < self.retry_times:
|
|
125
|
-
return self.request_with_retry(request, url_backup, domain_index, retry_count + 1, is_image,
|
|
135
|
+
return self.request_with_retry(request, url_backup, domain_index, retry_count + 1, is_image,
|
|
136
|
+
_retry_errors, **kwargs)
|
|
126
137
|
else:
|
|
127
|
-
return self.request_with_retry(request, url_backup, domain_index + 1, 0, is_image,
|
|
138
|
+
return self.request_with_retry(request, url_backup, domain_index + 1, 0, is_image,
|
|
139
|
+
_retry_errors, **kwargs)
|
|
128
140
|
|
|
129
141
|
# noinspection PyMethodMayBeStatic
|
|
130
142
|
def raise_if_resp_should_retry(self, resp, is_image):
|
|
@@ -212,10 +224,14 @@ class AbstractJmClient(
|
|
|
212
224
|
self.domain_list = domain_list
|
|
213
225
|
|
|
214
226
|
# noinspection PyUnusedLocal
|
|
215
|
-
def fallback(self, request, url, domain_index, retry_count, is_image, **kwargs):
|
|
227
|
+
def fallback(self, request, url, domain_index, retry_count, is_image, retry_errors=None, **kwargs):
|
|
216
228
|
msg = f"请求重试全部失败: [{url}], {self.domain_list}"
|
|
217
229
|
jm_log('req.fallback', msg)
|
|
218
|
-
ExceptionTool.raises(
|
|
230
|
+
ExceptionTool.raises(
|
|
231
|
+
msg,
|
|
232
|
+
{ExceptionTool.CONTEXT_KEY_RETRY_ERRORS: retry_errors or []},
|
|
233
|
+
RequestRetryAllFailException,
|
|
234
|
+
)
|
|
219
235
|
|
|
220
236
|
# noinspection PyMethodMayBeStatic
|
|
221
237
|
def append_params_to_url(self, url, params):
|
|
@@ -250,14 +266,12 @@ class JmHtmlClient(AbstractJmClient):
|
|
|
250
266
|
album_id,
|
|
251
267
|
folder_id='0',
|
|
252
268
|
):
|
|
253
|
-
|
|
254
|
-
'album_id': album_id,
|
|
255
|
-
'fid': folder_id,
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
resp = self.get_jm_html(
|
|
269
|
+
resp = self.post(
|
|
259
270
|
'/ajax/favorite_album',
|
|
260
|
-
data=
|
|
271
|
+
data={
|
|
272
|
+
'album_id': str(album_id),
|
|
273
|
+
'fid': str(folder_id),
|
|
274
|
+
},
|
|
261
275
|
)
|
|
262
276
|
|
|
263
277
|
res = resp.json()
|
|
@@ -274,6 +288,30 @@ class JmHtmlClient(AbstractJmClient):
|
|
|
274
288
|
|
|
275
289
|
return resp
|
|
276
290
|
|
|
291
|
+
def delete_favorite_album(self,
|
|
292
|
+
album_id,
|
|
293
|
+
folder_id='0',
|
|
294
|
+
):
|
|
295
|
+
resp = self.post(
|
|
296
|
+
'/ajax/delete_favorite_album',
|
|
297
|
+
data={
|
|
298
|
+
'album_id': str(album_id),
|
|
299
|
+
},
|
|
300
|
+
)
|
|
301
|
+
|
|
302
|
+
res = resp.json()
|
|
303
|
+
|
|
304
|
+
if res['status'] != 1:
|
|
305
|
+
msg = parse_unicode_escape_text(res['msg'])
|
|
306
|
+
error_msg = PatternTool.match_or_default(msg, JmcomicText.pattern_ajax_favorite_msg, msg)
|
|
307
|
+
|
|
308
|
+
self.raise_request_error(
|
|
309
|
+
resp,
|
|
310
|
+
error_msg
|
|
311
|
+
)
|
|
312
|
+
|
|
313
|
+
return resp
|
|
314
|
+
|
|
277
315
|
def get_album_detail(self, album_id) -> JmAlbumDetail:
|
|
278
316
|
return self.fetch_detail_entity(album_id, 'album')
|
|
279
317
|
|
|
@@ -423,7 +461,7 @@ class JmHtmlClient(AbstractJmClient):
|
|
|
423
461
|
|
|
424
462
|
def favorite_folder(self,
|
|
425
463
|
page=1,
|
|
426
|
-
order_by=JmMagicConstants.
|
|
464
|
+
order_by=JmMagicConstants.ORDER_FF_FAVORITE_TIME,
|
|
427
465
|
folder_id='0',
|
|
428
466
|
username='',
|
|
429
467
|
) -> JmFavoritePage:
|
|
@@ -887,7 +925,7 @@ class JmApiClient(AbstractJmClient):
|
|
|
887
925
|
|
|
888
926
|
def favorite_folder(self,
|
|
889
927
|
page=1,
|
|
890
|
-
order_by=JmMagicConstants.
|
|
928
|
+
order_by=JmMagicConstants.ORDER_FF_FAVORITE_TIME,
|
|
891
929
|
folder_id='0',
|
|
892
930
|
username='',
|
|
893
931
|
) -> JmFavoritePage:
|
|
@@ -942,15 +980,20 @@ class JmApiClient(AbstractJmClient):
|
|
|
942
980
|
)
|
|
943
981
|
return JmPageTool.parse_api_to_album_comment_page(resp.model_data, page)
|
|
944
982
|
|
|
945
|
-
def
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
983
|
+
def toggle_favorite_album(self,
|
|
984
|
+
album_id,
|
|
985
|
+
folder_id='0',
|
|
986
|
+
expected_type: Optional[str] = None,
|
|
987
|
+
):
|
|
949
988
|
"""
|
|
950
|
-
|
|
989
|
+
切换本子的收藏状态(移动端接口底层为 Toggle 逻辑)。
|
|
990
|
+
:param album_id: 本子ID
|
|
991
|
+
:param folder_id: 移动端没有提供 folder_id 参数,保留参数兼容
|
|
992
|
+
:param expected_type: 期望的操作类型 ('add' | 'remove'),如果不匹配则抛异常
|
|
951
993
|
"""
|
|
952
994
|
resp = self.req_api(
|
|
953
|
-
|
|
995
|
+
self.API_FAVORITE,
|
|
996
|
+
get=False,
|
|
954
997
|
data={
|
|
955
998
|
'aid': album_id,
|
|
956
999
|
},
|
|
@@ -958,8 +1001,36 @@ class JmApiClient(AbstractJmClient):
|
|
|
958
1001
|
|
|
959
1002
|
self.require_resp_status_ok(resp)
|
|
960
1003
|
|
|
1004
|
+
if expected_type is not None:
|
|
1005
|
+
actual_type = resp.model_data.type
|
|
1006
|
+
if actual_type != expected_type:
|
|
1007
|
+
ExceptionTool.raises_resp(
|
|
1008
|
+
f'收藏操作不符合预期,期望 [{expected_type}],实际为 [{actual_type}]: {resp.model_data.msg}',
|
|
1009
|
+
resp
|
|
1010
|
+
)
|
|
1011
|
+
|
|
961
1012
|
return resp
|
|
962
1013
|
|
|
1014
|
+
def add_favorite_album(self,
|
|
1015
|
+
album_id,
|
|
1016
|
+
folder_id='0',
|
|
1017
|
+
):
|
|
1018
|
+
"""
|
|
1019
|
+
把本子加入收藏夹。
|
|
1020
|
+
如果当前已收藏,将抛出异常以保证收藏语义明确。
|
|
1021
|
+
"""
|
|
1022
|
+
return self.toggle_favorite_album(album_id, folder_id, expected_type='add')
|
|
1023
|
+
|
|
1024
|
+
def delete_favorite_album(self,
|
|
1025
|
+
album_id,
|
|
1026
|
+
folder_id='0',
|
|
1027
|
+
):
|
|
1028
|
+
"""
|
|
1029
|
+
从收藏夹移除本子。
|
|
1030
|
+
如果当前未收藏,将抛出异常以保证取消收藏语义明确。
|
|
1031
|
+
"""
|
|
1032
|
+
return self.toggle_favorite_album(album_id, folder_id, expected_type='remove')
|
|
1033
|
+
|
|
963
1034
|
# noinspection PyMethodMayBeStatic
|
|
964
1035
|
def require_resp_status_ok(self, resp: JmApiResp):
|
|
965
1036
|
"""
|
|
@@ -290,7 +290,7 @@ class JmUserClient:
|
|
|
290
290
|
|
|
291
291
|
def favorite_folder(self,
|
|
292
292
|
page=1,
|
|
293
|
-
order_by=JmMagicConstants.
|
|
293
|
+
order_by=JmMagicConstants.ORDER_FF_FAVORITE_TIME,
|
|
294
294
|
folder_id='0',
|
|
295
295
|
username='',
|
|
296
296
|
) -> JmFavoritePage:
|
|
@@ -298,7 +298,7 @@ class JmUserClient:
|
|
|
298
298
|
获取收藏了的漫画,文件夹默认是全部
|
|
299
299
|
:param folder_id: 文件夹id
|
|
300
300
|
:param page: 分页
|
|
301
|
-
:param order_by:
|
|
301
|
+
:param order_by: 排序(JmMagicConstants.ORDER_FF_FAVORITE_TIME / ORDER_FF_UPDATE_TIME)
|
|
302
302
|
:param username: 用户名
|
|
303
303
|
"""
|
|
304
304
|
raise NotImplementedError
|
|
@@ -312,6 +312,15 @@ class JmUserClient:
|
|
|
312
312
|
"""
|
|
313
313
|
raise NotImplementedError
|
|
314
314
|
|
|
315
|
+
def delete_favorite_album(self,
|
|
316
|
+
album_id,
|
|
317
|
+
folder_id='0',
|
|
318
|
+
):
|
|
319
|
+
"""
|
|
320
|
+
从收藏夹移除漫画
|
|
321
|
+
"""
|
|
322
|
+
raise NotImplementedError
|
|
323
|
+
|
|
315
324
|
|
|
316
325
|
class JmImageClient:
|
|
317
326
|
|
|
@@ -609,7 +618,7 @@ class JmcomicClient(
|
|
|
609
618
|
|
|
610
619
|
def favorite_folder_gen(self,
|
|
611
620
|
page=1,
|
|
612
|
-
order_by=JmMagicConstants.
|
|
621
|
+
order_by=JmMagicConstants.ORDER_FF_FAVORITE_TIME,
|
|
613
622
|
folder_id='0',
|
|
614
623
|
username='',
|
|
615
624
|
) -> Generator[JmFavoritePage, Dict, None]:
|
|
@@ -1016,7 +1025,7 @@ class AsyncJmcomicClient:
|
|
|
1016
1025
|
|
|
1017
1026
|
async def favorite_folder(self,
|
|
1018
1027
|
page=1,
|
|
1019
|
-
order_by=JmMagicConstants.
|
|
1028
|
+
order_by=JmMagicConstants.ORDER_FF_FAVORITE_TIME,
|
|
1020
1029
|
folder_id='0',
|
|
1021
1030
|
username='',
|
|
1022
1031
|
) -> JmFavoritePage:
|
|
@@ -1024,7 +1033,7 @@ class AsyncJmcomicClient:
|
|
|
1024
1033
|
|
|
1025
1034
|
async def favorite_folder_gen(self,
|
|
1026
1035
|
page=1,
|
|
1027
|
-
order_by=JmMagicConstants.
|
|
1036
|
+
order_by=JmMagicConstants.ORDER_FF_FAVORITE_TIME,
|
|
1028
1037
|
folder_id='0',
|
|
1029
1038
|
username='',
|
|
1030
1039
|
):
|
|
@@ -1049,6 +1058,9 @@ class AsyncJmcomicClient:
|
|
|
1049
1058
|
async def add_favorite_album(self, album_id, folder_id='0'):
|
|
1050
1059
|
raise NotImplementedError
|
|
1051
1060
|
|
|
1061
|
+
async def delete_favorite_album(self, album_id, folder_id='0'):
|
|
1062
|
+
raise NotImplementedError
|
|
1063
|
+
|
|
1052
1064
|
async def album_comment(self,
|
|
1053
1065
|
video_id,
|
|
1054
1066
|
comment,
|
|
@@ -87,6 +87,10 @@ class JmMagicConstants:
|
|
|
87
87
|
ORDER_BY_SCORE = 'tr'
|
|
88
88
|
ORDER_BY_COMMENT = 'md'
|
|
89
89
|
|
|
90
|
+
# 收藏夹列表的排序参数(ff = favorite folder)
|
|
91
|
+
ORDER_FF_FAVORITE_TIME = 'mr' # 收藏时间
|
|
92
|
+
ORDER_FF_UPDATE_TIME = 'mp' # 更新时间
|
|
93
|
+
|
|
90
94
|
ORDER_MONTH_RANKING = 'mv_m'
|
|
91
95
|
ORDER_WEEK_RANKING = 'mv_w'
|
|
92
96
|
ORDER_DAY_RANKING = 'mv_t'
|
|
@@ -142,7 +146,7 @@ class JmMagicConstants:
|
|
|
142
146
|
APP_TOKEN_SECRET_2 = '18comicAPPContent'
|
|
143
147
|
APP_DATA_SECRET = '185Hcomic3PAPP7R'
|
|
144
148
|
API_DOMAIN_SERVER_SECRET = 'diosfjckwpqpdfjkvnqQjsik'
|
|
145
|
-
APP_VERSION = '2.
|
|
149
|
+
APP_VERSION = '2.1.6'
|
|
146
150
|
|
|
147
151
|
|
|
148
152
|
# 模块级别共用配置
|
|
@@ -63,6 +63,28 @@ class MissingAlbumPhotoException(ResponseUnexpectedException):
|
|
|
63
63
|
class RequestRetryAllFailException(JmcomicException):
|
|
64
64
|
description = '请求重试全部失败异常'
|
|
65
65
|
|
|
66
|
+
@property
|
|
67
|
+
def errors(self) -> list:
|
|
68
|
+
"""返回每次请求失败的记录,其中 error 为原始异常对象。"""
|
|
69
|
+
return self.context.get(ExceptionTool.CONTEXT_KEY_RETRY_ERRORS, [])
|
|
70
|
+
|
|
71
|
+
def __str__(self):
|
|
72
|
+
if not self.errors:
|
|
73
|
+
return super().__str__()
|
|
74
|
+
|
|
75
|
+
details = []
|
|
76
|
+
for index, item in enumerate(self.errors, 1):
|
|
77
|
+
error = item['error']
|
|
78
|
+
location = item.get('url') or item.get('domain') or '未知地址'
|
|
79
|
+
retry = item.get('retry')
|
|
80
|
+
retry_text = '' if retry is None else f', retry={retry}'
|
|
81
|
+
details.append(
|
|
82
|
+
f' {index}. {location}{retry_text}: '
|
|
83
|
+
f'{type(error).__name__}: {error}'
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
return f'{super().__str__()}\n失败详情:\n' + '\n'.join(details)
|
|
87
|
+
|
|
66
88
|
|
|
67
89
|
class PartialDownloadFailedException(JmcomicException):
|
|
68
90
|
description = '部分章节或图片下载失败异常'
|
|
@@ -84,6 +106,7 @@ class ExceptionTool:
|
|
|
84
106
|
CONTEXT_KEY_RE_PATTERN = 'pattern'
|
|
85
107
|
CONTEXT_KEY_MISSING_JM_ID = 'missing_jm_id'
|
|
86
108
|
CONTEXT_KEY_DOWNLOADER = 'downloader'
|
|
109
|
+
CONTEXT_KEY_RETRY_ERRORS = 'retry_errors'
|
|
87
110
|
|
|
88
111
|
@classmethod
|
|
89
112
|
def raises(cls,
|
|
@@ -827,6 +827,7 @@ class ProgressDownloader(JmDownloader):
|
|
|
827
827
|
self.stop_progress()
|
|
828
828
|
return super().__exit__(exc_type, exc_val, exc_tb)
|
|
829
829
|
|
|
830
|
+
|
|
830
831
|
# noinspection attribute-outside-init
|
|
831
832
|
class AsyncProgressDownloader(JmAsyncDownloader):
|
|
832
833
|
|
|
@@ -1785,6 +1786,7 @@ class AdvancedRetryPlugin(JmOptionPlugin):
|
|
|
1785
1786
|
|
|
1786
1787
|
retry_domain_max_times: int = self.retry_config['retry_domain_max_times']
|
|
1787
1788
|
retry_rounds: int = self.retry_config['retry_rounds']
|
|
1789
|
+
retry_errors = []
|
|
1788
1790
|
for rindex in range(retry_rounds):
|
|
1789
1791
|
domain_list = self.get_sorted_domain(client, retry_domain_max_times)
|
|
1790
1792
|
for i, domain in enumerate(domain_list):
|
|
@@ -1795,9 +1797,16 @@ class AdvancedRetryPlugin(JmOptionPlugin):
|
|
|
1795
1797
|
return do_request(domain)
|
|
1796
1798
|
except Exception as e:
|
|
1797
1799
|
jm_log('req.error', e)
|
|
1800
|
+
retry_errors.append({
|
|
1801
|
+
'domain': domain,
|
|
1802
|
+
'url': client.of_api_url(url, domain) if url.startswith('/') else url,
|
|
1803
|
+
'retry': rindex,
|
|
1804
|
+
'error': e,
|
|
1805
|
+
})
|
|
1798
1806
|
self.update_failed_count(client, domain)
|
|
1799
1807
|
|
|
1800
|
-
return client.fallback(request, url, 0, 0, is_image,
|
|
1808
|
+
return client.fallback(request, url, 0, 0, is_image,
|
|
1809
|
+
retry_errors=retry_errors, **kwargs)
|
|
1801
1810
|
|
|
1802
1811
|
def get_sorted_domain(self, client: JmcomicClient, times):
|
|
1803
1812
|
domain_list = client.get_domain_list()
|
|
@@ -185,7 +185,10 @@ class JmcomicText:
|
|
|
185
185
|
|
|
186
186
|
if field_value is None:
|
|
187
187
|
if default is None:
|
|
188
|
-
msg_tail = '' if JmModuleConfig.FLAG_DUMP_HTML_ON_REGEX_ERROR else
|
|
188
|
+
msg_tail = '' if JmModuleConfig.FLAG_DUMP_HTML_ON_REGEX_ERROR else \
|
|
189
|
+
(',可通过设置 JmModuleConfig.FLAG_DUMP_HTML_ON_REGEX_ERROR = True '
|
|
190
|
+
'将响应文本保存到文件'
|
|
191
|
+
)
|
|
189
192
|
ExceptionTool.raises_regex(
|
|
190
193
|
f"文本没有匹配上字段:字段名为'{field_name}',pattern: [{pattern}]"
|
|
191
194
|
+ (f"\n响应文本=[{html}]" if len(html) < 200 else
|
|
@@ -653,7 +656,7 @@ class JmPageTool:
|
|
|
653
656
|
)
|
|
654
657
|
|
|
655
658
|
# 收藏夹的收藏总数
|
|
656
|
-
pattern_html_favorite_total = compile(r'
|
|
659
|
+
pattern_html_favorite_total = compile(r'(?:總數|总数)\s*:\s*(\d+)\s*/\s*(\d+)')
|
|
657
660
|
|
|
658
661
|
# 所有的收藏夹
|
|
659
662
|
pattern_html_favorite_folder_list = [
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: jmcomic
|
|
3
|
-
Version: 2.7.
|
|
3
|
+
Version: 2.7.6
|
|
4
4
|
Summary: Python API For JMComic (禁漫天堂)
|
|
5
5
|
Home-page: https://github.com/hect0x7/JMComic-Crawler-Python
|
|
6
6
|
Author: hect0x7
|
|
@@ -120,7 +120,7 @@ Dynamic: requires-python
|
|
|
120
120
|
## 安装教程
|
|
121
121
|
|
|
122
122
|
> ⚠如果你没有安装过 Python,需要先前往 [Python 官网下载](https://www.python.org/downloads/) 再执行以下步骤。
|
|
123
|
-
>**推荐使用 Python 3.
|
|
123
|
+
>**推荐使用 Python 3.14**
|
|
124
124
|
|
|
125
125
|
* 通过pip官方源安装(推荐,并且更新也是这个命令)
|
|
126
126
|
|
|
@@ -312,8 +312,9 @@ jmv 350234 -y
|
|
|
312
312
|
|
|
313
313
|
## 使用小说明
|
|
314
314
|
|
|
315
|
-
* 推荐使用 **Python 3.
|
|
316
|
-
>
|
|
315
|
+
* 推荐使用 **Python 3.14**,目前 CI 只覆盖 Python 3.10 及以上版本。
|
|
316
|
+
> [!NOTE]
|
|
317
|
+
> Python 3.9 及更早版本均已结束官方支持 (EOL),使用3.9及以下随时有可能遇到第三方库不兼容的问题。Python 3.9 仍保留安装兼容,但不再纳入 CI。
|
|
317
318
|
|
|
318
319
|
* 个人项目,文档和示例会有不及时之处,可以Issue提问。
|
|
319
320
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|