feat: xhs支持获取评论的点赞数量

This commit is contained in:
Relakkes
2024-08-24 06:07:33 +08:00
parent ab7d8142af
commit 65699aa1cb
4 changed files with 65 additions and 1 deletions

View File

@@ -28,6 +28,14 @@ class XhsStoreFactory:
def get_video_url_arr(note_item: Dict) -> List:
"""
获取视频url数组
Args:
note_item:
Returns:
"""
if note_item.get('type') != 'video':
return []
@@ -47,6 +55,14 @@ def get_video_url_arr(note_item: Dict) -> List:
async def update_xhs_note(note_item: Dict):
"""
更新小红书笔记
Args:
note_item:
Returns:
"""
note_id = note_item.get("note_id")
user_info = note_item.get("user", {})
interact_info = note_item.get("interact_info", {})
@@ -86,6 +102,15 @@ async def update_xhs_note(note_item: Dict):
async def batch_update_xhs_note_comments(note_id: str, comments: List[Dict]):
"""
批量更新小红书笔记评论
Args:
note_id:
comments:
Returns:
"""
if not comments:
return
for comment_item in comments:
@@ -93,6 +118,15 @@ async def batch_update_xhs_note_comments(note_id: str, comments: List[Dict]):
async def update_xhs_note_comment(note_id: str, comment_item: Dict):
"""
更新小红书笔记评论
Args:
note_id:
comment_item:
Returns:
"""
user_info = comment_item.get("user_info", {})
comment_id = comment_item.get("id")
comment_pictures = [item.get("url_default", "") for item in comment_item.get("pictures", [])]
@@ -110,12 +144,22 @@ async def update_xhs_note_comment(note_id: str, comment_item: Dict):
"pictures": ",".join(comment_pictures),
"parent_comment_id": target_comment.get("id", 0),
"last_modify_ts": utils.get_current_timestamp(),
"like_count": comment_item.get("like_count", 0),
}
utils.logger.info(f"[store.xhs.update_xhs_note_comment] xhs note comment:{local_db_item}")
await XhsStoreFactory.create_store().store_comment(local_db_item)
async def save_creator(user_id: str, creator: Dict):
"""
保存小红书创作者
Args:
user_id:
creator:
Returns:
"""
user_info = creator.get('basicInfo', {})
follows = 0
@@ -148,5 +192,16 @@ async def save_creator(user_id: str, creator: Dict):
async def update_xhs_note_image(note_id, pic_content, extension_file_name):
"""
更新小红书笔
Args:
note_id:
pic_content:
extension_file_name:
Returns:
"""
await XiaoHongShuImage().store_image(
{"notice_id": note_id, "pic_content": pic_content, "extension_file_name": extension_file_name})