diff --git a/main.py b/main.py index e06606d..1fae021 100644 --- a/main.py +++ b/main.py @@ -130,9 +130,13 @@ class BiliWebCrawler: tag_url = f'https://api.bilibili.com/x/web-interface/view/detail/tag?bvid={self.bvid}' tag_resp = self._safe_request(tag_url) tag_data = [] - if tag_resp: - tag_json = tag_resp.json() - tag_data = [tag['tag_name'] for tag in tag_json.get('data', [])] + try: + if tag_resp: + tag_json = tag_resp.json() + tag_data = [tag['tag_name'] for tag in tag_json.get('data', [])] + except Exception as e: + print(f"获取视频标签失败: {str(e)}") + send_notification(f"获取视频{self.bvid}标签失败: {str(e)}") subtitle_data = [] try: @@ -147,17 +151,20 @@ class BiliWebCrawler: }) honor_data = [] - honors = video_data.get('honor', []) - if isinstance(honors, list): # 确保是列表类型 - for honor in honors: - if isinstance(honor, dict): # 检查是否为字典类型 - honor_data.append({ - 'type': honor.get('type', 0), - 'desc': honor.get('desc', '') - }) - # 如果honors是字符串则直接记录 - elif isinstance(honors, str): - honor_data.append({'desc': honors}) + try: + honors = video_data.get('honor', []) + if isinstance(honors, list): # 确保是列表类型 + for honor in honors: + if isinstance(honor, dict): # 检查是否为字典类型 + honor_data.append({ + 'type': honor.get('type', 0), + 'desc': honor.get('desc', '') + }) + # 如果honors是字符串则直接记录 + elif isinstance(honors, str): + honor_data.append({'desc': honors}) + except Exception as e: + honor_data = [] # 获取staff列表 try: