style(kuaishou): 优化终端日志输出为条目摘要

- 视频详情不再打印完整 JSON,改为单行摘要(id/作者/点赞/播放/标题)
- 搜索每页输出搜索到的视频条数
- 创作者输出获取到的视频总数
This commit is contained in:
程序员阿江(Relakkes)
2026-08-04 01:29:21 +08:00
parent 2e558f1352
commit 02294b9ea4

View File

@@ -178,6 +178,10 @@ class KuaishouCrawler(AbstractCrawler):
video_id_list.append(video_detail.get("photo", {}).get("id"))
await kuaishou_store.update_kuaishou_video(video_item=video_detail)
utils.logger.info(
f"[KuaishouCrawler.search] keyword: {keyword}, page: {page}, got {len(video_id_list)} videos"
)
# batch fetch video comments
page += 1
@@ -223,10 +227,17 @@ class KuaishouCrawler(AbstractCrawler):
await asyncio.sleep(config.CRAWLER_MAX_SLEEP_SEC)
utils.logger.info(f"[KuaishouCrawler.get_video_info_task] Sleeping for {config.CRAWLER_MAX_SLEEP_SEC} seconds after fetching video details {video_id}")
utils.logger.info(
f"[KuaishouCrawler.get_video_info_task] Get video_id:{video_id} info result: {result} ..."
)
return result.get("visionVideoDetail")
detail = result.get("visionVideoDetail")
if detail:
photo = detail.get("photo", {})
author = detail.get("author", {})
utils.logger.info(
f"[KuaishouCrawler.get_video_info_task] video detail: "
f"id={photo.get('id', video_id)} author={author.get('name', '')} "
f"likes={photo.get('likeCount', '')} views={photo.get('viewCount', '')} "
f"caption={str(photo.get('caption', ''))[:50]}"
)
return detail
except DataFetchError as ex:
utils.logger.error(
f"[KuaishouCrawler.get_video_info_task] Get video detail error: {ex}"
@@ -424,6 +435,9 @@ class KuaishouCrawler(AbstractCrawler):
crawl_interval=config.CRAWLER_MAX_SLEEP_SEC,
callback=self.fetch_creator_video_detail,
)
utils.logger.info(
f"[KuaishouCrawler.get_creators_and_videos] creator: {user_id}, got {len(all_video_list)} videos"
)
video_ids = [
video_item.get("photo", {}).get("id") for video_item in all_video_list