浏览代码

v1.0
服务上线

罗俊辉 1 年之前
父节点
当前提交
44c08e7885
共有 3 个文件被更改,包括 9 次插入13 次删除
  1. 4 4
      deal/matchArticle_deal.py
  2. 0 4
      spider/baidu_imgs.py
  3. 5 5
      task.py

+ 4 - 4
deal/matchArticle_deal.py

@@ -35,7 +35,7 @@ class MatchArticlesTask(object):
         执行定时任务,把库里面的视频转文本
         :return:
         """
-        select_sql = f"""SELECT video_id FROM {db_config} WHERE status_code = 0 ORDER BY id ASC limit 10;"""
+        select_sql = f"""SELECT video_id FROM {db_config} WHERE status_code = 0 ORDER BY id ASC limit 1;"""
         video_list = await self.mysql_client.select(select_sql)
 
         async def whisper_and_update(video_id, mysql_client):
@@ -65,7 +65,7 @@ class MatchArticlesTask(object):
         获取task的材料
         :return:
         """
-        select_sql = f"""SELECT task_id, video_title, video_text FROM {db_config} WHERE status_code = 1 ORDER BY id ASC limit 10;"""
+        select_sql = f"""SELECT task_id, video_title, video_text FROM {db_config} WHERE status_code = 1 ORDER BY id ASC limit 1;"""
         task_list = await self.mysql_client.select(select_sql)
 
         async def find_material(task_tuple, mysql_client):
@@ -95,7 +95,7 @@ class MatchArticlesTask(object):
         通过ai工具和材料来生成文章
         :return:
         """
-        select_sql = f"""SELECT task_id, video_title, materials FROM {db_config} WHERE status_code = 2 ORDER BY id ASC limit 10;"""
+        select_sql = f"""SELECT task_id, video_title, materials FROM {db_config} WHERE status_code = 2 ORDER BY id ASC limit 1;"""
         task_list = await self.mysql_client.select(sql=select_sql)
 
         async def ai_generate_text(task_tuple, mysql_client):
@@ -104,7 +104,7 @@ class MatchArticlesTask(object):
             imgs = get_img_list(video_title)
             update_sql = f"""
             UPDATE {db_config}
-            SET ai_text = '{ai_text}', ai_title = '{ai_title}', img_list = '{json.dumps(imgs, ensure_ascii=False)}',status_code = 3
+            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}';
             """
             print(update_sql)

+ 0 - 4
spider/baidu_imgs.py

@@ -52,7 +52,3 @@ def get_img_list(search_title):
     res = response.json()
     response = [i['ori'] for i in res[:15]]
     return response
-
-
-img_list = get_img_list("破纪录!中国年龄最大的夫妻,有什么长寿秘诀?")
-print(img_list)

+ 5 - 5
task.py

@@ -73,12 +73,12 @@ async def main():
     TMC = TaskMySQLClient()
     await TMC.init_pool()
     MAT = MatchArticlesTask(mysql_client=TMC)
-    # await MAT.whisper_task()
-    # await asyncio.sleep(120)
-    # await MAT.materials_task()
-    # await asyncio.sleep(120)
+    await MAT.whisper_task()
+    await asyncio.sleep(120)
+    await MAT.materials_task()
+    await asyncio.sleep(120)
     await MAT.ai_task()
-    # await asyncio.sleep(120)
+    await asyncio.sleep(120)
 
 
 if __name__ == '__main__':