|
@@ -8,7 +8,7 @@ import asyncio
|
|
|
from quart import Blueprint, jsonify, request
|
|
|
|
|
|
from applications.functions.log import logging
|
|
|
-from applications.schedule import recall_videos, search_videos
|
|
|
+from applications.schedule import recall_videos, search_videos, return_info_v2
|
|
|
|
|
|
my_blueprint = Blueprint('LongArticles', __name__)
|
|
|
|
|
@@ -38,46 +38,60 @@ def Routes(mysql_client):
|
|
|
:return:
|
|
|
"""
|
|
|
params = await request.get_json()
|
|
|
- gh_id = params['ghId']
|
|
|
- trace_id = "search-{}-{}".format(str(uuid.uuid4()), str(int(time.time())))
|
|
|
- params['trace_id'] = trace_id
|
|
|
- title = params['title'].split("@@")[-1].replace("'", "")
|
|
|
- contents = params['content'].replace("'", "")
|
|
|
- account_name = params['accountName'].replace("'", "")
|
|
|
- logging(
|
|
|
- code="2000",
|
|
|
- info="搜索视频内容接口请求成功",
|
|
|
- port="title_to_search",
|
|
|
- function="search_videos_from_the_web",
|
|
|
- trace_id=trace_id
|
|
|
- )
|
|
|
- insert_sql = f"""
|
|
|
- INSERT INTO long_articles_video
|
|
|
- (trace_id, gh_id, article_title, article_text, account_name)
|
|
|
- VALUES
|
|
|
- ('{trace_id}', '{gh_id}', '{title}', '{contents}', '{account_name}');"""
|
|
|
- await mysql_client.async_insert(insert_sql)
|
|
|
try:
|
|
|
- asyncio.ensure_future(
|
|
|
- search_videos(
|
|
|
- params=params,
|
|
|
- trace_id=trace_id,
|
|
|
- gh_id=gh_id,
|
|
|
- mysql_client=mysql_client
|
|
|
- )
|
|
|
+ gh_id = params['ghId']
|
|
|
+ trace_id = "search-{}-{}".format(str(uuid.uuid4()), str(int(time.time())))
|
|
|
+ params['trace_id'] = trace_id
|
|
|
+ title = params['title'].split("@@")[-1].replace("'", "")
|
|
|
+ contents = params['content'].replace("'", "")
|
|
|
+ account_name = params['accountName'].replace("'", "")
|
|
|
+ logging(
|
|
|
+ code="2000",
|
|
|
+ info="搜索视频内容接口请求成功",
|
|
|
+ port="title_to_search",
|
|
|
+ function="search_videos_from_the_web",
|
|
|
+ trace_id=trace_id
|
|
|
)
|
|
|
- res = {
|
|
|
- "status": "success",
|
|
|
- "code": 0,
|
|
|
- "traceId": trace_id
|
|
|
- }
|
|
|
except Exception as e:
|
|
|
- res = {
|
|
|
+ result = {
|
|
|
"status": "fail",
|
|
|
"code": 1,
|
|
|
- "message": str(e)
|
|
|
+ "message": str(e),
|
|
|
+ "info": "params check error"
|
|
|
}
|
|
|
- return jsonify(res)
|
|
|
+ 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)
|
|
|
+ else:
|
|
|
+ insert_sql = f"""
|
|
|
+ INSERT INTO long_articles_video
|
|
|
+ (trace_id, gh_id, article_title, article_text, account_name)
|
|
|
+ VALUES
|
|
|
+ ('{trace_id}', '{gh_id}', '{title}', '{contents}', '{account_name}');"""
|
|
|
+ await mysql_client.async_insert(insert_sql)
|
|
|
+ try:
|
|
|
+ asyncio.ensure_future(
|
|
|
+ search_videos(
|
|
|
+ params=params,
|
|
|
+ trace_id=trace_id,
|
|
|
+ gh_id=gh_id,
|
|
|
+ mysql_client=mysql_client
|
|
|
+ )
|
|
|
+ )
|
|
|
+ res = {
|
|
|
+ "status": "success",
|
|
|
+ "code": 0,
|
|
|
+ "traceId": trace_id
|
|
|
+ }
|
|
|
+ except Exception as e:
|
|
|
+ res = {
|
|
|
+ "status": "fail",
|
|
|
+ "code": 1,
|
|
|
+ "message": str(e)
|
|
|
+ }
|
|
|
+ return jsonify(res)
|
|
|
|
|
|
@my_blueprint.route('/recall_videos', methods=['POST'])
|
|
|
async def find_videos():
|