|
@@ -3,15 +3,12 @@
|
|
|
"""
|
|
|
from quart import Blueprint, jsonify, request
|
|
|
|
|
|
-from deal import RequestDeal
|
|
|
+from deal import VideoDeal
|
|
|
from deal import ArticleMatchAccount
|
|
|
-from deal import ArticleGeneral
|
|
|
-from deal import PublishDeal
|
|
|
-from deal import insert_text_mysql, get_text_by_id
|
|
|
from deal import ShareCard
|
|
|
from deal import SingleVideo
|
|
|
-from deal import MatchArticles
|
|
|
-from applications.functions import whisper
|
|
|
+from deal import MatchArticlesV1
|
|
|
+from deal import MatchArticlesV2
|
|
|
|
|
|
|
|
|
bp = Blueprint('VideosToArticle', __name__)
|
|
@@ -42,63 +39,10 @@ def VTARoutes(mysql_client):
|
|
|
:return:
|
|
|
"""
|
|
|
params = await request.get_json()
|
|
|
- RD = RequestDeal(params, mysql_client)
|
|
|
- result = await RD.deal()
|
|
|
+ VD = VideoDeal(params, mysql_client)
|
|
|
+ result = await VD.deal()
|
|
|
return jsonify(result)
|
|
|
|
|
|
- @bp.route('/whisper', methods=["POST"])
|
|
|
- async def video_extracting():
|
|
|
- """
|
|
|
- whisper 处理文本
|
|
|
- :return:
|
|
|
- """
|
|
|
- params = await request.get_json()
|
|
|
- video_id = params['vid']
|
|
|
- video_title = params['title']
|
|
|
- try:
|
|
|
- response = whisper(video_id)
|
|
|
- result = await insert_text_mysql(mysql_client, video_id, response['text'], video_title)
|
|
|
- except Exception as e:
|
|
|
- result = {"error": str(e), "vid": video_id}
|
|
|
- return jsonify(result)
|
|
|
-
|
|
|
- @bp.route('/get_text', methods=["POST"])
|
|
|
- async def get_video_text():
|
|
|
- """
|
|
|
- 获取视频文本
|
|
|
- :return:
|
|
|
- """
|
|
|
- params = await request.get_json()
|
|
|
- video_id = params['vid']
|
|
|
- text = await get_text_by_id(mysql_client, video_id)
|
|
|
- if text:
|
|
|
- result = {"text": text}
|
|
|
- else:
|
|
|
- result = {"text": None}
|
|
|
- return jsonify(result)
|
|
|
-
|
|
|
- @bp.route('/publish', methods=["POST"])
|
|
|
- async def auto_publish():
|
|
|
- """
|
|
|
- auto publish article info to aigc system
|
|
|
- :return:
|
|
|
- """
|
|
|
- params = await request.get_json()
|
|
|
- P = PublishDeal(params=params)
|
|
|
- res = P.deal()
|
|
|
- return jsonify(res)
|
|
|
-
|
|
|
- @bp.route('/article', methods=["POST"])
|
|
|
- async def generate_text():
|
|
|
- """
|
|
|
- 生成文本
|
|
|
- :return:
|
|
|
- """
|
|
|
- params = await request.get_json()
|
|
|
- A = ArticleGeneral(params=params)
|
|
|
- res = A.deal()
|
|
|
- return jsonify(res)
|
|
|
-
|
|
|
@bp.route("/match", methods=["POST"])
|
|
|
async def match_account():
|
|
|
"""
|
|
@@ -132,19 +76,25 @@ def VTARoutes(mysql_client):
|
|
|
response = SV.deal()
|
|
|
return jsonify(response)
|
|
|
|
|
|
- @bp.route("/matchArticle", methods=["POST"])
|
|
|
+ @bp.route("/matchArticleV1", methods=["POST"])
|
|
|
async def match_article():
|
|
|
"""
|
|
|
匹配视频
|
|
|
:return:
|
|
|
"""
|
|
|
params = await request.get_json()
|
|
|
- MA = MatchArticles(params=params)
|
|
|
- result = MA.deal()
|
|
|
- response = {
|
|
|
- "status": "success",
|
|
|
- "article": result
|
|
|
- }
|
|
|
+ MA = MatchArticlesV1(params=params, mysql_client=mysql_client)
|
|
|
+ response = await MA.deal()
|
|
|
+ return jsonify(response)
|
|
|
+
|
|
|
+ @bp.route("/matchArticleV2", methods=["POST"])
|
|
|
+ async def recall_article():
|
|
|
+ """
|
|
|
+ Recall Article
|
|
|
+ """
|
|
|
+ params = await request.get_json()
|
|
|
+ MA2 = MatchArticlesV2(params=params, mysql_client=mysql_client)
|
|
|
+ response = await MA2.recall_articles()
|
|
|
return jsonify(response)
|
|
|
|
|
|
return bp
|