|
@@ -10,6 +10,7 @@ from quart import Blueprint, jsonify, request
|
|
|
from applications.functions.log import logging
|
|
|
from applications.schedule import ProcessParams, search_videos
|
|
|
from applications.functions.common import KimiServer, MySQLServer
|
|
|
+from applications.schedule.main_schedule import AskForInfo
|
|
|
|
|
|
my_blueprint = Blueprint('kimi', __name__)
|
|
|
|
|
@@ -46,36 +47,36 @@ async def search_videos_from_the_web():
|
|
|
function="search_videos_from_the_web",
|
|
|
trace_id=trace_id
|
|
|
)
|
|
|
- # try:
|
|
|
- title_p = os.path.join(os.getcwd(), 'applications', 'static', "titles", "{}.json".format(title))
|
|
|
- if os.path.exists(title_p):
|
|
|
- logging(
|
|
|
- code="2001",
|
|
|
- info="该标题已经被 kimi 处理过,跳过请求 kimi 操作--- {}".format(title),
|
|
|
- function="search_videos_from_the_web",
|
|
|
- trace_id=trace_id
|
|
|
+ try:
|
|
|
+ title_p = os.path.join(os.getcwd(), 'applications', 'static', "titles", "{}.json".format(title))
|
|
|
+ if os.path.exists(title_p):
|
|
|
+ logging(
|
|
|
+ code="2001",
|
|
|
+ info="该标题已经被 kimi 处理过,跳过请求 kimi 操作--- {}".format(title),
|
|
|
+ function="search_videos_from_the_web",
|
|
|
+ trace_id=trace_id
|
|
|
+ )
|
|
|
+ else:
|
|
|
+ KimiServer().ask_kimi_and_save_to_local((title, trace_id, title_p))
|
|
|
+ await asyncio.sleep(1)
|
|
|
+ kimi_title = KimiServer().kimi_title(title)
|
|
|
+ search_videos(
|
|
|
+ title=title,
|
|
|
+ video_path=title_p,
|
|
|
+ trace_id=trace_id,
|
|
|
+ gh_id=gh_id,
|
|
|
)
|
|
|
- else:
|
|
|
- KimiServer().ask_kimi_and_save_to_local((title, trace_id, title_p))
|
|
|
- await asyncio.sleep(1)
|
|
|
- kimi_title = KimiServer().kimi_title(title)
|
|
|
- search_videos(
|
|
|
- title=title,
|
|
|
- video_path=title_p,
|
|
|
- trace_id=trace_id,
|
|
|
- gh_id=gh_id,
|
|
|
- )
|
|
|
- res = {
|
|
|
- "trace_id": trace_id,
|
|
|
- "code": 0,
|
|
|
- "kimi_title": kimi_title
|
|
|
- }
|
|
|
- # except Exception as e:
|
|
|
- # res = {
|
|
|
- # "trace_id": trace_id,
|
|
|
- # "code": 1,
|
|
|
- # "message": str(e)
|
|
|
- # }
|
|
|
+ res = {
|
|
|
+ "trace_id": trace_id,
|
|
|
+ "code": 0,
|
|
|
+ "kimi_title": kimi_title
|
|
|
+ }
|
|
|
+ except Exception as e:
|
|
|
+ res = {
|
|
|
+ "trace_id": trace_id,
|
|
|
+ "code": 1,
|
|
|
+ "message": str(e)
|
|
|
+ }
|
|
|
return jsonify(res)
|
|
|
|
|
|
|
|
@@ -98,7 +99,7 @@ async def find_in_mysql():
|
|
|
return jsonify(res)
|
|
|
|
|
|
|
|
|
-@my_blueprint.route('/title_to_video', methods=['POST'])
|
|
|
+@my_blueprint.route('/find_video', methods=['POST'])
|
|
|
async def post_data():
|
|
|
"""
|
|
|
请求接口代码
|
|
@@ -115,3 +116,16 @@ async def post_data():
|
|
|
p = ProcessParams(t_id=trace_id)
|
|
|
processed_data = await p.deal(data)
|
|
|
return jsonify(processed_data)
|
|
|
+
|
|
|
+
|
|
|
+@my_blueprint.route('/title_to_video', methods=['POST'])
|
|
|
+async def delay_response():
|
|
|
+ """
|
|
|
+ main
|
|
|
+ :return:
|
|
|
+ """
|
|
|
+ # 从请求体中解析 JSON 数据
|
|
|
+ data = await request.get_json()
|
|
|
+ A = AskForInfo(data)
|
|
|
+ res = A.schedule()
|
|
|
+ return jsonify(res)
|