123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152 |
- """
- @author: luojunhui
- """
- from quart import Blueprint, jsonify, request
- from deal import RequestDeal
- 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
- bp = Blueprint('VideosToArticle', __name__)
- def VTARoutes(mysql_client):
- """
- :param mysql_client:
- :return:
- """
- @bp.route("/healthcheck")
- def hello_world():
- """
- Health Check Port
- :return:
- """
- result = {
- "status": "success",
- "msg": "Hello Future"
- }
- return jsonify(result)
- @bp.route('/videos', methods=["POST"])
- async def find_videos():
- """
- 更具接口获取视频信息
- :return:
- """
- params = await request.get_json()
- RD = RequestDeal(params, mysql_client)
- result = await RD.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():
- """
- 匹配小程序
- :return:
- """
- params = await request.get_json()
- MA = ArticleMatchAccount(params=params)
- res = MA.deal()
- return jsonify(res)
- @bp.route("/getShareCard", methods=["POST"])
- async def get_share_cards():
- """
- 获取分享卡片
- :return:
- """
- params = await request.get_json()
- SC = ShareCard(params=params)
- response = SC.deal()
- return jsonify(response)
- @bp.route("/singleVideo", methods=["POST"])
- async def find_video_info():
- """
- 获取单个视频的信息
- :return:
- """
- params = await request.get_json()
- SV = SingleVideo(params=params)
- response = SV.deal()
- return jsonify(response)
- @bp.route("/matchArticle", methods=["POST"])
- async def match_article():
- """
- 匹配视频
- :return:
- """
- params = await request.get_json()
- MA = MatchArticles(params=params)
- result = MA.deal()
- response = {
- "status": "success",
- "article": result
- }
- return jsonify(response)
- return bp
|