add:comments

This commit is contained in:
Sheyiyuan 2025-03-24 09:10:24 +08:00
parent cd48dee45c
commit 5398eb06d7

13
main.py
View File

@ -157,6 +157,16 @@ class BiliWebCrawler:
elif isinstance(honors, str): elif isinstance(honors, str):
honor_data.append({'desc': honors}) honor_data.append({'desc': honors})
# 获取staff列表
try:
staff= video_data.get('staff', [])
if len(staff)>0:
is_unity_up = True
else:
is_unity_up = False
except Exception as e:
is_unity_up = False
info = { info = {
'BV号': self.bvid, 'BV号': self.bvid,
'title': video_data.get('title', ''), 'title': video_data.get('title', ''),
@ -174,6 +184,7 @@ class BiliWebCrawler:
'发布时间': time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(video_data.get('pubdate', 0))), '发布时间': time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(video_data.get('pubdate', 0))),
'分区': video_data.get('tname', ''), '分区': video_data.get('tname', ''),
'标签': tag_data, '标签': tag_data,
'是否为联合投稿': is_unity_up,
'视频方向': self._get_video_orientation(video_data.get('dimension', {})), '视频方向': self._get_video_orientation(video_data.get('dimension', {})),
'视频最高分辨率': resolution_str, '视频最高分辨率': resolution_str,
'视频类型': ["","自制", "转载"][video_data.get('copyright', 0)], '视频类型': ["","自制", "转载"][video_data.get('copyright', 0)],
@ -292,7 +303,7 @@ class BiliWebCrawler:
}) })
return danmaku return danmaku
def get_comments(self, max_pages=1000): def get_comments(self, max_pages=5):
"""获取热门评论,仅保留一级评论""" """获取热门评论,仅保留一级评论"""
if not self.aid: if not self.aid:
send_notification("未找到视频 ID无法获取评论数据。") send_notification("未找到视频 ID无法获取评论数据。")