Commit 061b6795 authored by Yaowentong's avatar Yaowentong

元宝修复

parent 07661504
......@@ -99,6 +99,22 @@ def yuanbao_android_process_rich_media(url_list):
quto_list.append(raw_data)
return quto_list
def yuanbao_process_rich_media(url_list):
quto_list = []
for item in url_list:
video_id = item.get('mediaId', '')
raw_data = {
"video_id": video_id,
"video_captions": item.get('title', ''),
"video_first_frame_image": item.get('url', '') or item.get('resourceUrl') or '',
"main_site_url": '',
"source_app_name": '视频号'
}
quto_list.append(raw_data)
return quto_list
def doubao_process_rich_media(url_list):
quto_list = []
......@@ -273,7 +289,7 @@ def yuanbao_process_quote(url_list):
"snippet": item.get('quote', ''),
"index": item.get('index', ''),
"published_at": item.get('publish_time', ''),
"site_name": item.get('web_site_name', ''),
"site_name": item.get('web_site_name', '') or item.get('webSiteSource', ''),
"site_icon": item.get('icon_url', ''),
}
quto_list.append(raw_data)
......@@ -289,7 +305,7 @@ def yuanbao_android_process_quote(url_list):
"snippet": item.get('quote', ''),
"index": item.get('index', ''),
"published_at": item.get('publish_time', ''),
"site_name": item.get('web_site_name', ''),
"site_name": item.get('web_site_name', '') or item.get('webSiteSource', ''),
"site_icon": item.get('icon_url', ''),
}
quto_list.append(raw_data)
......@@ -445,6 +461,8 @@ def save_data_to_tos(target_dir, content, file_name):
content = qianwen_process_rich_media(content)
if platform == 'TXYBA':
content = yuanbao_android_process_rich_media(content)
if platform == 'TXYB':
content = yuanbao_process_rich_media(content)
if file_name == "quote.txt":
if platform == 'DB':
......
......@@ -35,6 +35,7 @@ def yuanbao_android_process_original_data(data):
except (IndexError, json.JSONDecodeError):
continue # 跳过格式错误的数据
if json_data.get('type') == 'searchGuid':
url_list = json_data.get('docs')
if json_data.get('type') == 'think':
think_content += json_data.get('content')
......@@ -107,7 +108,7 @@ if __name__ == '__main__':
# yuanbao_android_process_original_data(file_path2)
data_list = bh_utils.query_data(f"select * from geo_commit_task where taskId = '539a80f8-cd2d-4ae7-a45c-2b2d41fa738e' and platform = 'TXYBA'")
data_list = bh_utils.query_data(f"select * from geo_commit_task where taskId = '30fde623-70a3-4ca7-86fb-393b60841402' and platform = 'TXYBA'")
# # #
# # #
......
......@@ -30,7 +30,6 @@ def yuanbao_process_original_data(data):
# 提取并解析JSON数据
data_str = i.split("data: ")[1]
json_data = json.loads(data_str)
except (IndexError, json.JSONDecodeError):
continue # 跳过格式错误的数据
......@@ -49,8 +48,12 @@ def yuanbao_process_original_data(data):
# response_content += json_data.get('contents')[0].get('msg')
if json_data.get('type') == 'image':
response_content = "生成了图片"
if json_data.get('type') == 'replace':
if json_data.get('replace').get('display') =='videoBoxV2':
rich_media_block.extend(json_data.get('replace').get('multimedias'))
spider_save_tos.process_and_save_files(file_path, search_keyword, url_list, think_content, response_content,
suggestions)
suggestions,rich_media_block)
return (file_path, search_keyword, url_list, think_content, response_content, suggestions)
except Exception as e:
parts = file_path.split('/')
......@@ -76,7 +79,7 @@ def yuanbao_process_original_data(data):
return (file_path, search_keyword, url_list, think_content, response_content, suggestions)
if __name__ == '__main__':
data_list = bh_utils.query_data(f"select * from geo_commit_task where taskId = '69189ba0-e443-4e7c-a465-cabc07973540' and platform = 'TXYB'")
data_list = bh_utils.query_data(f"select * from geo_commit_task where taskId = '30fde623-70a3-4ca7-86fb-393b60841402' and platform = 'TXYB'")
# # #
# # #
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment