diff --git a/assets/docs/sources/images/github_actions_tutorial.jpg b/assets/docs/sources/images/github_actions_tutorial.jpg new file mode 100644 index 000000000..88bc25064 Binary files /dev/null and b/assets/docs/sources/images/github_actions_tutorial.jpg differ diff --git a/assets/docs/sources/tutorial/1_github_actions.md b/assets/docs/sources/tutorial/1_github_actions.md index 1ef0173ef..92087c89d 100644 --- a/assets/docs/sources/tutorial/1_github_actions.md +++ b/assets/docs/sources/tutorial/1_github_actions.md @@ -1,5 +1,8 @@ # GitHub Actions使用教程 + +![tutorial](../images/github_actions_tutorial.jpg) + 一共需要三步: 1. fork一份我的代码仓库。 diff --git a/src/jmcomic/__init__.py b/src/jmcomic/__init__.py index 04e0300eb..0c32715de 100644 --- a/src/jmcomic/__init__.py +++ b/src/jmcomic/__init__.py @@ -2,7 +2,7 @@ # 被依赖方 <--- 使用方 # config <--- entity <--- toolkit <--- client <--- option <--- downloader -__version__ = '2.6.12' +__version__ = '2.6.13' from .api import * from .jm_plugin import * diff --git a/src/jmcomic/jm_client_impl.py b/src/jmcomic/jm_client_impl.py index d98fa98ba..bf0b5a500 100644 --- a/src/jmcomic/jm_client_impl.py +++ b/src/jmcomic/jm_client_impl.py @@ -699,7 +699,17 @@ def get_scramble_id(self, photo_id, album_id=None): def fetch_detail_entity(self, jmid, clazz): """ - 请求实体类 + Fetches a JM entity (album or chapter) by its JM ID and returns it as an instance of `clazz`. + + Parameters: + jmid (str | int): JM ID or value parseable to a JM ID. + clazz (type): Entity class to parse the response into (e.g., `JmAlbumDetail` or a chapter/detail class). + + Returns: + object: An instance of `clazz` populated from the API response data. + + Raises: + Exception: Raised via ExceptionTool.raise_missing if the API response lacks required data. """ jmid = JmcomicText.parse_to_jm_id(jmid) url = self.API_ALBUM if issubclass(clazz, JmAlbumDetail) else self.API_CHAPTER @@ -710,7 +720,7 @@ def fetch_detail_entity(self, jmid, clazz): }) ) - if resp.res_data.get('name') is None: + if not resp.encoded_data or resp.res_data.get('name') is None: ExceptionTool.raise_missing(resp, jmid) 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) - if scramble_id != '': photo.scramble_id = scramble_id - return photo + return photo \ No newline at end of file diff --git a/tests/test_jmcomic/test_jm_client.py b/tests/test_jmcomic/test_jm_client.py index d4cf4d8d2..046631e97 100644 --- a/tests/test_jmcomic/test_jm_client.py +++ b/tests/test_jmcomic/test_jm_client.py @@ -39,13 +39,25 @@ def test_gt_300_photo(self): self.client.download_by_image_detail(image, self.option.decide_image_filepath(image)) def test_album_missing(self): + """ + Verify get_album_detail raises MissingAlbumPhotoException for a missing album. + + Asserts that requesting album with ID '530595' causes a MissingAlbumPhotoException to be raised. + """ self.assertRaises( MissingAlbumPhotoException, self.client.get_album_detail, - '0' + '530595' ) def test_detail_property_list(self): + """ + Validate that selected property lists of album 410090 match expected values after conversion to Chinese. + + Fetches album detail for ID 410090 and compares the first up to nine entries of its `works`, `actors`, `tags`, + and `authors` lists against expected values, converting both sides with `JmcomicText.to_zh_cn` before asserting + element-wise equality. + """ album = self.client.get_album_detail(410090) ans = [ @@ -337,3 +349,11 @@ def test_download_cover(self): album_id = 123 self.client.download_album_cover(album_id, f'{self.option.dir_rule.base_dir}/{album_id}.webp') self.client.download_album_cover(album_id, f'{self.option.dir_rule.base_dir}/{album_id}_3x4.webp', '_3x4') + + def test_ranking(self): + """ + Fetches and prints the jmcomic monthly ranking for current month. + + This test retrieves the page 1 ranking data from the configured client and writes it to standard output. + """ + print(self.client.month_ranking(1))