Skip to content

Commit 620a094

Browse files
authored
v2.6.13: 修复app端接口判断本子不存在的逻辑,actions教程添加图片 (#512)
1 parent e39e3a1 commit 620a094

5 files changed

Lines changed: 38 additions & 5 deletions

File tree

566 KB
Loading

assets/docs/sources/tutorial/1_github_actions.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# GitHub Actions使用教程
22

3+
4+
![tutorial](../images/github_actions_tutorial.jpg)
5+
36
一共需要三步:
47

58
1. fork一份我的代码仓库。

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.6.12'
5+
__version__ = '2.6.13'
66

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

src/jmcomic/jm_client_impl.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,17 @@ def get_scramble_id(self, photo_id, album_id=None):
699699

700700
def fetch_detail_entity(self, jmid, clazz):
701701
"""
702-
请求实体类
702+
Fetches a JM entity (album or chapter) by its JM ID and returns it as an instance of `clazz`.
703+
704+
Parameters:
705+
jmid (str | int): JM ID or value parseable to a JM ID.
706+
clazz (type): Entity class to parse the response into (e.g., `JmAlbumDetail` or a chapter/detail class).
707+
708+
Returns:
709+
object: An instance of `clazz` populated from the API response data.
710+
711+
Raises:
712+
Exception: Raised via ExceptionTool.raise_missing if the API response lacks required data.
703713
"""
704714
jmid = JmcomicText.parse_to_jm_id(jmid)
705715
url = self.API_ALBUM if issubclass(clazz, JmAlbumDetail) else self.API_CHAPTER
@@ -710,7 +720,7 @@ def fetch_detail_entity(self, jmid, clazz):
710720
})
711721
)
712722

713-
if resp.res_data.get('name') is None:
723+
if not resp.encoded_data or resp.res_data.get('name') is None:
714724
ExceptionTool.raise_missing(resp, jmid)
715725

716726
return JmApiAdaptTool.parse_entity(resp.res_data, clazz)
@@ -1195,4 +1205,4 @@ def get_photo_detail(self, photo_id, fetch_album=True, fetch_scramble_id=True) -
11951205
if scramble_id != '':
11961206
photo.scramble_id = scramble_id
11971207

1198-
return photo
1208+
return photo

tests/test_jmcomic/test_jm_client.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,25 @@ def test_gt_300_photo(self):
3939
self.client.download_by_image_detail(image, self.option.decide_image_filepath(image))
4040

4141
def test_album_missing(self):
42+
"""
43+
Verify get_album_detail raises MissingAlbumPhotoException for a missing album.
44+
45+
Asserts that requesting album with ID '530595' causes a MissingAlbumPhotoException to be raised.
46+
"""
4247
self.assertRaises(
4348
MissingAlbumPhotoException,
4449
self.client.get_album_detail,
45-
'0'
50+
'530595'
4651
)
4752

4853
def test_detail_property_list(self):
54+
"""
55+
Validate that selected property lists of album 410090 match expected values after conversion to Chinese.
56+
57+
Fetches album detail for ID 410090 and compares the first up to nine entries of its `works`, `actors`, `tags`,
58+
and `authors` lists against expected values, converting both sides with `JmcomicText.to_zh_cn` before asserting
59+
element-wise equality.
60+
"""
4961
album = self.client.get_album_detail(410090)
5062

5163
ans = [
@@ -337,3 +349,11 @@ def test_download_cover(self):
337349
album_id = 123
338350
self.client.download_album_cover(album_id, f'{self.option.dir_rule.base_dir}/{album_id}.webp')
339351
self.client.download_album_cover(album_id, f'{self.option.dir_rule.base_dir}/{album_id}_3x4.webp', '_3x4')
352+
353+
def test_ranking(self):
354+
"""
355+
Fetches and prints the jmcomic monthly ranking for current month.
356+
357+
This test retrieves the page 1 ranking data from the configured client and writes it to standard output.
358+
"""
359+
print(self.client.month_ranking(1))

0 commit comments

Comments
 (0)