瀏覽代碼

兼容新服务

罗俊辉 11 月之前
父節點
當前提交
ce0ce4ae7c
共有 2 個文件被更改,包括 39 次插入15 次删除
  1. 12 2
      applications/routes.py
  2. 27 13
      applications/schedule/process_schedule.py

+ 12 - 2
applications/routes.py

@@ -62,8 +62,18 @@ def Routes(mysql_client):
             return jsonify(result)
         if "video_id=" in title:
             video_id = title.split("video_id=")[-1]
-            result = await return_info_v2(video_id=video_id, trace_id=trace_id)
-            return jsonify(result)
+            insert_sql = f"""
+                            INSERT INTO long_articles_video 
+                                (trace_id, gh_id, article_title, article_text, account_name, recall_video_id1)
+                            VALUES 
+                                ('{trace_id}', '{gh_id}', '{title}', '{contents}', '{account_name}', '{video_id}');"""
+            await mysql_client.async_insert(insert_sql)
+            res = {
+                "status": "success",
+                "code": 0,
+                "traceId": trace_id
+            }
+            return jsonify(res)
         else:
             insert_sql = f"""
                 INSERT INTO long_articles_video 

+ 27 - 13
applications/schedule/process_schedule.py

@@ -8,8 +8,9 @@ from applications.functions.common import request_for_info, create_gzh_path
 from applications.functions.log import logging
 
 
-async def return_info_v2(video_id, trace_id):
+async def return_info_v2(video_id, trace_id, mysql_client):
     """
+    :param mysql_client:
     :param trace_id:
     :param video_id:
     :return:
@@ -42,6 +43,15 @@ async def return_info_v2(video_id, trace_id):
         "videoUrl": videoUrl,
         "paragraphPosition": 0.25
     }
+    update_result_sql = f"""
+                        UPDATE long_articles_video
+                        SET
+                            result1 = '{json.dumps(result, ensure_ascii=False)}',
+                            success = 1
+                        WHERE
+                            trace_id = '{trace_id}'
+                    """
+    await mysql_client.async_insert(update_result_sql)
     logging(
         code="2000",
         info="root_share_id和source_id",
@@ -53,10 +63,7 @@ async def return_info_v2(video_id, trace_id):
             "sourceId": source_id
         }
     )
-    return {
-        "traceId": trace_id,
-        "miniprogramList": [result]
-    }
+    return result
 
 
 async def return_info(video_id, kimi_title, trace_id, mysql_client, index):
@@ -128,7 +135,7 @@ async def recall_videos(trace_id, mysql_client):
     :return:
     """
     select_sql = f"""
-        SELECT recall_video_id1,recall_video_id2, recall_video_id3, kimi_title 
+        SELECT recall_video_id1, recall_video_id2, recall_video_id3, kimi_title 
         FROM long_articles_video
         WHERE trace_id = '{trace_id}';
     """
@@ -145,13 +152,20 @@ async def recall_videos(trace_id, mysql_client):
             trace_id=trace_id
         )
         for index, best_video_id in enumerate(unEmptyList, 1):
-            temp = await return_info(
-                video_id=best_video_id,
-                kimi_title=kimi_title,
-                trace_id=trace_id,
-                mysql_client=mysql_client,
-                index=index
-            )
+            if kimi_title:
+                temp = await return_info(
+                    video_id=best_video_id,
+                    kimi_title=kimi_title,
+                    trace_id=trace_id,
+                    mysql_client=mysql_client,
+                    index=index
+                )
+            else:
+                temp = await return_info_v2(
+                    video_id=best_video_id,
+                    trace_id=trace_id,
+                    mysql_client=mysql_client
+                )
             L.append(temp)
         result = {
             "traceId": trace_id,