|
@@ -45,17 +45,21 @@ class MatchArticlesTask(object):
|
|
:param mysql_client:
|
|
:param mysql_client:
|
|
:return:
|
|
:return:
|
|
"""
|
|
"""
|
|
- w_response = whisper(video_id)
|
|
|
|
|
|
+ try:
|
|
|
|
+ w_response = whisper(video_id)
|
|
|
|
+ except:
|
|
|
|
+ w_response = {"text": "whisper failed"}
|
|
print(w_response)
|
|
print(w_response)
|
|
text = w_response['text'].replace("'", "")
|
|
text = w_response['text'].replace("'", "")
|
|
update_sql = f"""
|
|
update_sql = f"""
|
|
UPDATE {db_config}
|
|
UPDATE {db_config}
|
|
SET
|
|
SET
|
|
- video_text = '{text}',
|
|
|
|
- status_code = 1
|
|
|
|
- WHERE video_id = {video_id};
|
|
|
|
|
|
+ video_text = %s,
|
|
|
|
+ status_code = %s
|
|
|
|
+ WHERE video_id = %s;
|
|
"""
|
|
"""
|
|
- await mysql_client.async_insert(sql=update_sql)
|
|
|
|
|
|
+ print(update_sql)
|
|
|
|
+ await mysql_client.async_insert(sql=update_sql, params=(text, 1, video_id))
|
|
|
|
|
|
for vid in video_list:
|
|
for vid in video_list:
|
|
await whisper_and_update(video_id=vid[0], mysql_client=self.mysql_client)
|
|
await whisper_and_update(video_id=vid[0], mysql_client=self.mysql_client)
|
|
@@ -82,11 +86,11 @@ class MatchArticlesTask(object):
|
|
material_result = json.dumps(material_dict, ensure_ascii=False)
|
|
material_result = json.dumps(material_dict, ensure_ascii=False)
|
|
update_sql = f"""
|
|
update_sql = f"""
|
|
UPDATE {db_config}
|
|
UPDATE {db_config}
|
|
- SET materials = '{material_result}', status_code = 2
|
|
|
|
- WHERE task_id = '{task_id}';
|
|
|
|
|
|
+ SET materials = %s, status_code = %s
|
|
|
|
+ WHERE task_id = %s;
|
|
"""
|
|
"""
|
|
print(update_sql)
|
|
print(update_sql)
|
|
- await mysql_client.async_insert(sql=update_sql)
|
|
|
|
|
|
+ await mysql_client.async_insert(sql=update_sql, params=(material_result, 2, task_id))
|
|
|
|
|
|
for task in task_list:
|
|
for task in task_list:
|
|
await find_material(task, self.mysql_client)
|
|
await find_material(task, self.mysql_client)
|
|
@@ -105,11 +109,21 @@ class MatchArticlesTask(object):
|
|
imgs = get_img_list(video_title)
|
|
imgs = get_img_list(video_title)
|
|
update_sql = f"""
|
|
update_sql = f"""
|
|
UPDATE {db_config}
|
|
UPDATE {db_config}
|
|
- SET ai_text = '{ai_text}', ai_title = '{ai_title}', cover = '{imgs[0]}',img_list = '{json.dumps(imgs, ensure_ascii=False)}',status_code = 3
|
|
|
|
- WHERE task_id = '{task_id}';
|
|
|
|
|
|
+ SET ai_text = %s, ai_title = %s, cover = %s, img_list = %s, status_code = %s
|
|
|
|
+ WHERE task_id = %s;
|
|
"""
|
|
"""
|
|
print(update_sql)
|
|
print(update_sql)
|
|
- await mysql_client.async_insert(sql=update_sql)
|
|
|
|
|
|
+ await mysql_client.async_insert(
|
|
|
|
+ sql=update_sql,
|
|
|
|
+ params=(
|
|
|
|
+ ai_text,
|
|
|
|
+ ai_title,
|
|
|
|
+ imgs[0],
|
|
|
|
+ json.dumps(imgs, ensure_ascii=False),
|
|
|
|
+ 3,
|
|
|
|
+ task_id
|
|
|
|
+ )
|
|
|
|
+ )
|
|
|
|
|
|
for task in task_list:
|
|
for task in task_list:
|
|
await ai_generate_text(task, self.mysql_client)
|
|
await ai_generate_text(task, self.mysql_client)
|
|
@@ -153,9 +167,17 @@ class MatchArticlesV1(object):
|
|
INSERT INTO {db_config}
|
|
INSERT INTO {db_config}
|
|
(video_id, task_id, video_title, request_time)
|
|
(video_id, task_id, video_title, request_time)
|
|
VALUES
|
|
VALUES
|
|
- ({self.video_id}, '{request_id}', '{self.title}', {request_time})
|
|
|
|
|
|
+ (%s, %s, %s, %s)
|
|
"""
|
|
"""
|
|
- await self.mysql_client.async_insert(sql=insert_sql)
|
|
|
|
|
|
+ await self.mysql_client.async_insert(
|
|
|
|
+ sql=insert_sql,
|
|
|
|
+ params=(
|
|
|
|
+ self.video_id,
|
|
|
|
+ request_id,
|
|
|
|
+ self.title,
|
|
|
|
+ request_time
|
|
|
|
+ )
|
|
|
|
+ )
|
|
return request_id
|
|
return request_id
|
|
|
|
|
|
async def deal(self):
|
|
async def deal(self):
|