-
Notifications
You must be signed in to change notification settings - Fork 2.6k
add fetch_douyin_hot_search_result endpoint #696
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
RenYuanSir
wants to merge
1
commit into
Evil0ctal:main
Choose a base branch
from
RenYuanSir:feat_douyin_hot_search
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+32
−0
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -566,6 +566,38 @@ async def fetch_video_comments_reply(request: Request, | |||||||||||||||||||||||||||||||||
| raise HTTPException(status_code=status_code, detail=detail.dict()) | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| # 获取抖音热榜数据 | ||||||||||||||||||||||||||||||||||
| @router.get("/fetch_hot_search_result", | ||||||||||||||||||||||||||||||||||
| response_model=ResponseModel, | ||||||||||||||||||||||||||||||||||
| summary="获取抖音热榜数据/Get Douyin hot search data") | ||||||||||||||||||||||||||||||||||
| async def fetch_hot_search_result(request: Request): | ||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||
| # [中文] | ||||||||||||||||||||||||||||||||||
| ### 用途: | ||||||||||||||||||||||||||||||||||
| - 获取抖音热榜数据 | ||||||||||||||||||||||||||||||||||
| ### 返回: | ||||||||||||||||||||||||||||||||||
| - 热榜数据 | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| # [English] | ||||||||||||||||||||||||||||||||||
| ### Purpose: | ||||||||||||||||||||||||||||||||||
| - Get Douyin hot search data | ||||||||||||||||||||||||||||||||||
| ### Return: | ||||||||||||||||||||||||||||||||||
| - Hot search data | ||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||
| try: | ||||||||||||||||||||||||||||||||||
| data = await DouyinWebCrawler.fetch_hot_search_result() | ||||||||||||||||||||||||||||||||||
| return ResponseModel(code=200, | ||||||||||||||||||||||||||||||||||
| router=request.url.path, | ||||||||||||||||||||||||||||||||||
| data=data) | ||||||||||||||||||||||||||||||||||
| except Exception as e: | ||||||||||||||||||||||||||||||||||
| status_code = 400 | ||||||||||||||||||||||||||||||||||
| detail = ErrorResponseModel(code=status_code, | ||||||||||||||||||||||||||||||||||
| router=request.url.path, | ||||||||||||||||||||||||||||||||||
| params=dict(request.query_params), | ||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||
| raise HTTPException(status_code=status_code, detail=detail.dict()) | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+592
to
+598
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Warning 当前 except Exception as e 分支中没有使用/记录 e,导致线上排障困难;同时会触发 lint(未使用变量)。建议至少记录异常(logger.exception)或将异常信息(经过脱敏)附加到 detail 中(更推荐日志)。 建议: 在模块内引入 logger 并使用 logger.exception 记录堆栈;同时避免未使用变量告警。
Suggested change
|
||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| # 生成真实msToken | ||||||||||||||||||||||||||||||||||
| @router.get("/generate_real_msToken", | ||||||||||||||||||||||||||||||||||
| response_model=ResponseModel, | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tip
💡 路径命名与 PR 标题不一致,且缺少 douyin 前缀可能造成路由语义不清/后续冲突
PR 标题为 add fetch_douyin_hot_search_result endpoint,但实际路由为 /fetch_hot_search_result。若项目还有其他平台/来源的 hot search,缺少 douyin 前缀可能导致命名冲突或文档语义不清。
建议: 若无历史兼容性要求,考虑将路由改为 /fetch_douyin_hot_search_result 或 /douyin/fetch_hot_search_result,并同步更新 summary/文档。若需要保持兼容,可新增新路由并保留旧路由做别名。