Skip to content
Merged

Dev #19

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
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,3 +198,15 @@ tag指的搜索关键词,可以是标签,作者,标题等等,num则代
**Method: `GET`**

只需要传入通知中返回的 `file_name`,即可将打包的 zip 文件返回,文件名格式为 `"{file_name}.zip"`。

## 感谢以下项目

### 禁漫Python爬虫

<a href="https://github.com/hect0x7/JMComic-Crawler-Python">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://github-readme-stats.vercel.app/api/pin/?username=hect0x7&repo=JMComic-Crawler-Python&theme=radical" />
<source media="(prefers-color-scheme: light)" srcset="https://github-readme-stats.vercel.app/api/pin/?username=hect0x7&repo=JMComic-Crawler-Python" />
<img alt="Repo Card" src="https://github-readme-stats.vercel.app/api/pin/?username=hect0x7&repo=JMComic-Crawler-Python" />
</picture>
</a>
9 changes: 0 additions & 9 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,8 +367,6 @@ async def download_file(file_name: str):
)


# --- 其他原有路由 (保持不变) ---

@app.get("/v1/{timestamp}")
async def read_root(timestamp: float):
"""
Comment on lines 367 to 372
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Improvement in Error Messaging

The error handling in lines [367-372] could be enhanced by providing more specific error messages based on the type of error encountered (e.g., file not found, access denied, etc.). Currently, the generic message 'File not found or has expired.' does not give enough information about what went wrong, which can hinder troubleshooting and user experience.

Recommendation:
Enhance the error handling by catching specific exceptions and returning more descriptive error messages. This will help in diagnosing issues more effectively and improve the clarity of communication to the end-user.

Expand Down Expand Up @@ -493,12 +491,6 @@ async def rank(searchTime: str):
return cached_result

client = get_jm_client()
pages: jmcomic.JmCategoryPage = client.categories_filter(
page=1,
time=jmcomic.JmMagicConstants.TIME_ALL,
category=jmcomic.JmMagicConstants.CATEGORY_ALL,
order_by=jmcomic.JmMagicConstants.ORDER_BY_LATEST,
)
if searchTime == "month":
pages: jmcomic.JmCategoryPage = client.month_ranking(1)
elif searchTime == "week":
Comment on lines 491 to 496
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Lack of Error Handling and Validation

The function rank retrieves ranking data based on the searchTime parameter but does not handle potential errors from the client method calls nor validates the searchTime input. This could lead to unhandled exceptions or incorrect data retrieval if searchTime is not one of the expected values ('month', 'week', 'day').

Recommendation:

  1. Validate searchTime to ensure it matches one of the expected values before proceeding with the method calls.
  2. Implement error handling for the client method calls to manage exceptions and provide appropriate feedback or fallbacks.

Expand All @@ -515,5 +507,4 @@ async def rank(searchTime: str):


if __name__ == '__main__':
# 确保 uvicorn 运行时引用的是当前文件的 app 实例
uvicorn.run("main:app", host="0.0.0.0", log_level="info")
Comment on lines 509 to 510
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Security Concern: Server Exposure

The application is configured to listen on all network interfaces (0.0.0.0), which could expose the server to unwanted external access if not properly secured.

Recommendation:
Consider binding the server to 127.0.0.1 if it is only meant for local access. If remote access is required, ensure that appropriate security measures such as firewalls and authentication are in place to protect the server.