mirror of
https://github.com/NanmiCoder/MediaCrawler.git
synced 2026-02-24 00:50:47 +08:00
feat: add like_count field to bilibi for issue #623
This commit is contained in:
@@ -592,3 +592,4 @@ alter table douyin_aweme_comment add column `like_count` varchar(255) NOT NULL D
|
||||
|
||||
alter table xhs_note add column xsec_token varchar(50) default null comment '签名算法';
|
||||
alter table douyin_aweme_comment add column `pictures` varchar(500) NOT NULL DEFAULT '' COMMENT '评论图片列表';
|
||||
alter table bilibili_video_comment add column `like_count` varchar(255) NOT NULL DEFAULT '0' COMMENT '点赞数';
|
||||
@@ -1,12 +1,12 @@
|
||||
# 声明:本代码仅供学习和研究目的使用。使用者应遵守以下原则:
|
||||
# 1. 不得用于任何商业用途。
|
||||
# 2. 使用时应遵守目标平台的使用条款和robots.txt规则。
|
||||
# 3. 不得进行大规模爬取或对平台造成运营干扰。
|
||||
# 4. 应合理控制请求频率,避免给目标平台带来不必要的负担。
|
||||
# 声明:本代码仅供学习和研究目的使用。使用者应遵守以下原则:
|
||||
# 1. 不得用于任何商业用途。
|
||||
# 2. 使用时应遵守目标平台的使用条款和robots.txt规则。
|
||||
# 3. 不得进行大规模爬取或对平台造成运营干扰。
|
||||
# 4. 应合理控制请求频率,避免给目标平台带来不必要的负担。
|
||||
# 5. 不得用于任何非法或不当的用途。
|
||||
#
|
||||
# 详细许可条款请参阅项目根目录下的LICENSE文件。
|
||||
# 使用本代码即表示您同意遵守上述原则和LICENSE中的所有条款。
|
||||
#
|
||||
# 详细许可条款请参阅项目根目录下的LICENSE文件。
|
||||
# 使用本代码即表示您同意遵守上述原则和LICENSE中的所有条款。
|
||||
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
@@ -27,7 +27,7 @@ class BiliStoreFactory:
|
||||
STORES = {
|
||||
"csv": BiliCsvStoreImplement,
|
||||
"db": BiliDbStoreImplement,
|
||||
"json": BiliJsonStoreImplement
|
||||
"json": BiliJsonStoreImplement,
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
@@ -35,7 +35,8 @@ class BiliStoreFactory:
|
||||
store_class = BiliStoreFactory.STORES.get(config.SAVE_DATA_OPTION)
|
||||
if not store_class:
|
||||
raise ValueError(
|
||||
"[BiliStoreFactory.create_store] Invalid save option only supported csv or db or json ...")
|
||||
"[BiliStoreFactory.create_store] Invalid save option only supported csv or db or json ..."
|
||||
)
|
||||
return store_class()
|
||||
|
||||
|
||||
@@ -67,7 +68,8 @@ async def update_bilibili_video(video_item: Dict):
|
||||
"source_keyword": source_keyword_var.get(),
|
||||
}
|
||||
utils.logger.info(
|
||||
f"[store.bilibili.update_bilibili_video] bilibili video id:{video_id}, title:{save_content_item.get('title')}")
|
||||
f"[store.bilibili.update_bilibili_video] bilibili video id:{video_id}, title:{save_content_item.get('title')}"
|
||||
)
|
||||
await BiliStoreFactory.create_store().store_content(content_item=save_content_item)
|
||||
|
||||
|
||||
@@ -87,7 +89,8 @@ async def update_up_info(video_item: Dict):
|
||||
"is_official": video_item_card.get("official_verify").get("type"),
|
||||
}
|
||||
utils.logger.info(
|
||||
f"[store.bilibili.update_up_info] bilibili user_id:{video_item_card.get('mid')}")
|
||||
f"[store.bilibili.update_up_info] bilibili user_id:{video_item_card.get('mid')}"
|
||||
)
|
||||
await BiliStoreFactory.create_store().store_creator(creator=saver_up_info)
|
||||
|
||||
|
||||
@@ -103,6 +106,7 @@ async def update_bilibili_video_comment(video_id: str, comment_item: Dict):
|
||||
parent_comment_id = str(comment_item.get("parent", 0))
|
||||
content: Dict = comment_item.get("content")
|
||||
user_info: Dict = comment_item.get("member")
|
||||
like_count: int = comment_item.get("like", 0)
|
||||
save_comment_item = {
|
||||
"comment_id": comment_id,
|
||||
"parent_comment_id": parent_comment_id,
|
||||
@@ -115,10 +119,12 @@ async def update_bilibili_video_comment(video_id: str, comment_item: Dict):
|
||||
"sign": user_info.get("sign"),
|
||||
"avatar": user_info.get("avatar"),
|
||||
"sub_comment_count": str(comment_item.get("rcount", 0)),
|
||||
"like_count": like_count,
|
||||
"last_modify_ts": utils.get_current_timestamp(),
|
||||
}
|
||||
utils.logger.info(
|
||||
f"[store.bilibili.update_bilibili_video_comment] Bilibili video comment: {comment_id}, content: {save_comment_item.get('content')}")
|
||||
f"[store.bilibili.update_bilibili_video_comment] Bilibili video comment: {comment_id}, content: {save_comment_item.get('content')}"
|
||||
)
|
||||
await BiliStoreFactory.create_store().store_comment(comment_item=save_comment_item)
|
||||
|
||||
|
||||
@@ -131,7 +137,12 @@ async def store_video(aid, video_content, extension_file_name):
|
||||
extension_file_name:
|
||||
"""
|
||||
await BilibiliVideo().store_video(
|
||||
{"aid": aid, "video_content": video_content, "extension_file_name": extension_file_name})
|
||||
{
|
||||
"aid": aid,
|
||||
"video_content": video_content,
|
||||
"extension_file_name": extension_file_name,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
async def batch_update_bilibili_creator_fans(creator_info: Dict, fans_list: List[Dict]):
|
||||
@@ -144,10 +155,14 @@ async def batch_update_bilibili_creator_fans(creator_info: Dict, fans_list: List
|
||||
"sign": fan_item.get("sign"),
|
||||
"avatar": fan_item.get("face"),
|
||||
}
|
||||
await update_bilibili_creator_contact(creator_info=creator_info, fan_info=fan_info)
|
||||
await update_bilibili_creator_contact(
|
||||
creator_info=creator_info, fan_info=fan_info
|
||||
)
|
||||
|
||||
|
||||
async def batch_update_bilibili_creator_followings(creator_info: Dict, followings_list: List[Dict]):
|
||||
async def batch_update_bilibili_creator_followings(
|
||||
creator_info: Dict, followings_list: List[Dict]
|
||||
):
|
||||
if not followings_list:
|
||||
return
|
||||
for following_item in followings_list:
|
||||
@@ -157,10 +172,14 @@ async def batch_update_bilibili_creator_followings(creator_info: Dict, following
|
||||
"sign": following_item.get("sign"),
|
||||
"avatar": following_item.get("face"),
|
||||
}
|
||||
await update_bilibili_creator_contact(creator_info=following_info, fan_info=creator_info)
|
||||
await update_bilibili_creator_contact(
|
||||
creator_info=following_info, fan_info=creator_info
|
||||
)
|
||||
|
||||
|
||||
async def batch_update_bilibili_creator_dynamics(creator_info: Dict, dynamics_list: List[Dict]):
|
||||
async def batch_update_bilibili_creator_dynamics(
|
||||
creator_info: Dict, dynamics_list: List[Dict]
|
||||
):
|
||||
if not dynamics_list:
|
||||
return
|
||||
for dynamic_item in dynamics_list:
|
||||
@@ -183,7 +202,9 @@ async def batch_update_bilibili_creator_dynamics(creator_info: Dict, dynamics_li
|
||||
"total_forwards": dynamic_forward,
|
||||
"total_liked": dynamic_like,
|
||||
}
|
||||
await update_bilibili_creator_dynamic(creator_info=creator_info, dynamic_info=dynamic_info)
|
||||
await update_bilibili_creator_dynamic(
|
||||
creator_info=creator_info, dynamic_info=dynamic_info
|
||||
)
|
||||
|
||||
|
||||
async def update_bilibili_creator_contact(creator_info: Dict, fan_info: Dict):
|
||||
|
||||
Reference in New Issue
Block a user