Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/release_auto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ on:
jobs:
release:
runs-on: ubuntu-latest
permissions:
id-token: write
if: startsWith(github.event.head_commit.message, 'v')
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -40,5 +42,5 @@ jobs:
- name: Release PYPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_JMCOMIC }}
# with:
# password: ${{ secrets.PYPI_JMCOMIC }}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ jmcomic 123

## 使用小说明

* Python >= 3.7
* Python >= 3.7,建议3.9以上,因为jmcomic的依赖库可能会不支持3.9以下的版本。
* 个人项目,文档和示例会有不及时之处,可以Issue提问

## 项目文件夹介绍
Expand Down
12 changes: 7 additions & 5 deletions assets/docs/sources/tutorial/0_common_usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ client = JmOption.default().new_jm_client()

# 分页查询,search_site就是禁漫网页上的【站内搜索】
page: JmSearchPage = client.search_site(search_query='+MANA +无修正', page=1)
print(f'结果总数: {page.total}, 分页大小: {page.page_size},页数: {page.page_count}')

# page默认的迭代方式是page.iter_id_title(),每次迭代返回 albun_id, title
for album_id, title in page:
print(f'[{album_id}]: {title}')
Expand Down Expand Up @@ -168,10 +170,10 @@ from jmcomic import *

option = JmOption.default()
client = option.new_jm_client()
client.login('用户名', '密码') # 也可以使用login插件/配置cookies
client.login('用户名', '密码') # 也可以使用login插件/配置cookies

# 遍历全部收藏的所有页
for page in cl.favorite_folder_gen(): # 如果你只想获取特定收藏夹,需要添加folder_id参数
for page in client.favorite_folder_gen(): # 如果你只想获取特定收藏夹,需要添加folder_id参数
# 遍历每页结果
for aid, atitle in page.iter_id_title():
# aid: 本子的album_id
Expand All @@ -183,9 +185,9 @@ for page in cl.favorite_folder_gen(): # 如果你只想获取特定收藏夹,

# 获取特定收藏夹的单页,使用favorite_folder方法
page = client.favorite_folder(page=1,
order_by=JmMagicConstants.ORDER_BY_LATEST,
folder_id='0' # 收藏夹id
)
order_by=JmMagicConstants.ORDER_BY_LATEST,
folder_id='0' # 收藏夹id
)
```

## 分类 / 排行榜
Expand Down
44 changes: 44 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
[build-system]
requires = ["setuptools"]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Specify an explicit minimum setuptools version and include wheel

PEP-517/518 front-ends expect the build backend to be able to build wheels. Without a wheel requirement older environments will fail, and setuptools < 61.0 will ignore most of the PEP 621 metadata used below.

-requires = ["setuptools"]
+requires = ["setuptools>=61", "wheel"]
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
requires = ["setuptools"]
requires = ["setuptools>=61", "wheel"]
🤖 Prompt for AI Agents
In pyproject.toml at line 2, update the requires list to specify a minimum
setuptools version of 61.0 or higher and add wheel as a required build
dependency. This ensures compatibility with PEP 517/518 front-ends and proper
handling of PEP 621 metadata by requiring setuptools >= 61.0 and including wheel
for building wheels.


[project]
name = "jmcomic"
authors = [{name = "hect0x7", email = "93357912+hect0x7@users.noreply.github.com"}]
description = "Python API For JMComic (禁漫天堂)"
readme = "README.md"
requires-python = ">=3.7"
license = {file = "LICENSE"}
keywords=['python', 'jmcomic', '18comic', '禁漫天堂', 'NSFW']
classifiers=[
"Development Status :: 4 - Beta",
"License :: OSI Approved :: MIT License",
"Intended Audience :: Developers",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
Comment on lines +16 to +22
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Programming Language :: Python :: 3.13 is not (yet) a valid PyPI trove classifier

Uploading the package will be rejected by PyPI until that classifier is officially added. Remove or comment it out for now.

-    "Programming Language :: Python :: 3.13",
🤖 Prompt for AI Agents
In pyproject.toml around lines 14 to 20, the classifier "Programming Language ::
Python :: 3.13" is not yet valid on PyPI and will cause upload rejection. Remove
or comment out this line to ensure the package can be uploaded successfully.

"Operating System :: MacOS",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Incorrect OS classifier – use the canonical “MacOS :: MacOS X”

"Operating System :: MacOS" is invalid. The accepted classifier is:

-    "Operating System :: MacOS",
+    "Operating System :: MacOS :: MacOS X",
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"Operating System :: MacOS",
"Operating System :: MacOS :: MacOS X",
🤖 Prompt for AI Agents
In pyproject.toml at line 21, the operating system classifier "Operating System
:: MacOS" is incorrect. Replace it with the canonical classifier "Operating
System :: MacOS :: MacOS X" to comply with accepted Python package classifiers.

"Operating System :: POSIX :: Linux",
"Operating System :: Microsoft :: Windows",
]
dependencies = [
"commonx>=0.6.38",
"curl-cffi",
"pillow",
"pycryptodome",
"pyyaml",
]
Comment on lines +27 to +33
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Pin or bound the remaining dependencies

All runtime dependencies except commonx are completely unpinned, which can lead to sudden breakage on fresh installs. At minimum, declare a lower bound that is known to work, e.g.:

-    "curl-cffi",
-    "pillow",
-    "pycryptodome",
-    "pyyaml",
+    "curl-cffi>=0.6",
+    "pillow>=10.0",
+    "pycryptodome>=3.19",
+    "pyyaml>=6.0",
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
dependencies = [
"commonx>=0.6.38",
"curl-cffi",
"pillow",
"pycryptodome",
"pyyaml",
]
dependencies = [
"commonx>=0.6.38",
"curl-cffi>=0.6",
"pillow>=10.0",
"pycryptodome>=3.19",
"pyyaml>=6.0",
]
🤖 Prompt for AI Agents
In pyproject.toml around lines 25 to 31, the dependencies other than commonx are
unpinned, risking breakage on fresh installs. Add version constraints with lower
bounds for curl-cffi, pillow, pycryptodome, and pyyaml that are known to work,
using syntax like "package>=version" to ensure compatibility and stability.

dynamic = ["version"]

[project.urls]
Homepage = "https://github.com/hect0x7/JMComic-Crawler-Python"
Documentation = "https://jmcomic.readthedocs.io"

[project.scripts]
jmcomic = "jmcomic.cl:main"

[tool.setuptools.dynamic]
version = {attr = "jmcomic.__version__"}
2 changes: 1 addition & 1 deletion src/jmcomic/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# 被依赖方 <--- 使用方
# config <--- entity <--- toolkit <--- client <--- option <--- downloader

__version__ = '2.6.2'
__version__ = '2.6.3'

from .api import *
from .jm_plugin import *
Expand Down
2 changes: 1 addition & 1 deletion src/jmcomic/jm_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class JmModuleConfig:
''')

# 获取最新移动端API域名的地址
API_URL_DOMAIN_SERVER = f'{PROT}jmappc01-1308024008.cos.ap-guangzhou.myqcloud.com/server-2024.txt'
API_URL_DOMAIN_SERVER = f'{PROT}jmapp03-1308024008.cos.ap-jakarta.myqcloud.com/server-2024.txt'

APP_HEADERS_TEMPLATE = {
'Accept-Encoding': 'gzip, deflate',
Expand Down
1 change: 1 addition & 0 deletions tests/test_jmcomic/test_jm_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def test_fetch_album(self):

def test_search(self):
page: JmSearchPage = self.client.search_tag('+无修正 +中文 -全彩')
print(f'总数: {page.total}, 分页大小: {page.page_size},页数: {page.page_count}')
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Avoid prints in tests & confirm page_size is an int

  1. Printing inside tests clutters CI output.
  2. page.page_size looks like a property, but if it is a method it will print <bound method …> and break the page_count math.
-        print(f'总数: {page.total}, 分页大小: {page.page_size},页数: {page.page_count}')
+        # Assert pagination meta instead of printing
+        import math
+        self.assertIsInstance(page.total, int)
+        self.assertGreater(page.total, 0)
+        self.assertIsInstance(page.page_size, int)
+        self.assertGreater(page.page_size, 0)
+        self.assertEqual(page.page_count,
+                         math.ceil(page.total / page.page_size))

If page_size is actually a method, decorate it with @property so callers (including the existing page_count implementation) work correctly.


🏁 Script executed:

#!/bin/bash
set -e

echo "1. Inspecting test file around line 20:"
sed -n '1,50p' tests/test_jmcomic/test_jm_client.py || true

echo
echo "2. Locating the Page class definition:"
rg -n "class Page" || echo "No Page class found"

echo
echo "3. Checking for a page_size method or property:"
rg -n -C2 "def page_size" || echo "No page_size method defined"
rg -n "@property.*page_size" || echo "No @property decorator on page_size"

echo
echo "4. Searching for page_count implementation to see how it uses page_size:"
rg -n "page_count" -C2 || echo "No page_count reference found"

Length of output: 7199


🏁 Script executed:

#!/bin/bash
set -e

echo "1. Inspect property page_count implementation in jm_entity.py:"
sed -n '580,630p' src/jmcomic/jm_entity.py || true

echo
echo "2. Locate the JmSearchPage class to see how total and page_count are set:"
rg -n "class JmSearchPage" -C5 src/jmcomic/jm_entity.py || true

Length of output: 1861


Avoid prints in tests & assert pagination metadata

The print in test_search clutters CI output. Instead, verify pagination values with assertions. Since page_size is already a @property returning an int, no decorator changes are needed.

• File: tests/test_jmcomic/test_jm_client.py (line 20)
• Replace:

-        print(f'总数: {page.total}, 分页大小: {page.page_size},页数: {page.page_count}')
+        import math
+        # Assert pagination metadata
+        self.assertIsInstance(page.total, int)
+        self.assertGreater(page.total, 0)
+        self.assertIsInstance(page.page_size, int)
+        self.assertGreater(page.page_size, 0)
+        self.assertEqual(
+            page.page_count,
+            math.ceil(page.total / page.page_size)
+        )

No changes required to the page_size property—it already returns an int as intended.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
print(f'总数: {page.total}, 分页大小: {page.page_size},页数: {page.page_count}')
import math
# Assert pagination metadata
self.assertIsInstance(page.total, int)
self.assertGreater(page.total, 0)
self.assertIsInstance(page.page_size, int)
self.assertGreater(page.page_size, 0)
self.assertEqual(
page.page_count,
math.ceil(page.total / page.page_size)
)
🤖 Prompt for AI Agents
In tests/test_jmcomic/test_jm_client.py at line 20, replace the print statement
that outputs pagination metadata with assertions that verify the expected values
of page.total, page.page_size, and page.page_count. This removes clutter from CI
output and ensures the test validates pagination correctly without modifying the
existing page_size property.


if len(page) >= 1:
for aid, ainfo in page[0:1:1]:
Expand Down