12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- from tqdm import tqdm
- from pymysql.cursors import DictCursor
- from applications.api import fetch_piaoquan_video_list_detail
- from applications.db import DatabaseConnector
- from config import denet_config, long_articles_config
- denet_client = DatabaseConnector(denet_config)
- denet_client.connect()
- lam_client = DatabaseConnector(long_articles_config)
- lam_client.connect()
- # step 1, get publish_content_id var publish_content_plan
- sql = f"""
- select id, crawler_channel_content_id, source_id, publish_stage_id, t2.channel_content_id
- from publish_content t1
- join produce_plan_exe_record t2 on t1.source_id = t2.plan_exe_id
- where t1.plan_id = '20250520112612679208238' and t1.status = 2;
- """
- success_task_list = denet_client.fetch(sql, cursor_type=DictCursor)
- ori_publish_id_list = []
- ori_publish_content_id_publish_stage_id_dict = {}
- for task in tqdm(success_task_list):
- # step2, get channel_channel_content_id var source_id
- channel_content_id = task['channel_content_id'].replace(task['crawler_channel_content_id'], '').replace('#', '')
- # step3, get ori_source_id as content_id
- video_id = task['publish_stage_id']
- if video_id:
- # continue
- try:
- pq_video_detail = fetch_piaoquan_video_list_detail([video_id])
- video_oss_path = pq_video_detail['data'][0]['ossVideoPath']
- title = pq_video_detail['data'][0]['title']
- update_query = f"""
- update ai_video_ab_test
- set title = %s, pq_video_id = %s, video_oss_path = %s, status = %s
- where new_channel_content_id = %s and status = %s;
- """
- affected_rows = lam_client.save(update_query, (title, video_id, video_oss_path, 1, channel_content_id, 0))
- print(affected_rows)
- except Exception as e:
- print(e)
- print(video_id)
- else:
- print(task)
- #
- # L = {}
- # for task in response:
- # publish_content_id = task['id']
- # source_id = task['source_id']
- # L[source_id] = ori_publish_content_id_publish_stage_id_dict[publish_content_id]
- #
- # print(json.dumps(L, indent=4, ensure_ascii=False))
|