vta_routes.py 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. """
  2. @author: luojunhui
  3. """
  4. from quart import Blueprint, jsonify, request
  5. from deal import VideoDeal
  6. from deal import ArticleMatchAccount
  7. from deal import ShareCard
  8. from deal import SingleVideo
  9. from deal import MatchArticlesV1
  10. from deal import MatchArticlesV2
  11. bp = Blueprint('VideosToArticle', __name__)
  12. def VTARoutes(mysql_client):
  13. """
  14. :param mysql_client:
  15. :return:
  16. """
  17. @bp.route("/healthcheck")
  18. def hello_world():
  19. """
  20. Health Check Port
  21. :return:
  22. """
  23. result = {
  24. "status": "success",
  25. "msg": "Hello Future"
  26. }
  27. return jsonify(result)
  28. @bp.route('/videos', methods=["POST"])
  29. async def find_videos():
  30. """
  31. 更具接口获取视频信息
  32. :return:
  33. """
  34. params = await request.get_json()
  35. VD = VideoDeal(params, mysql_client)
  36. result = await VD.deal()
  37. return jsonify(result)
  38. @bp.route("/match", methods=["POST"])
  39. async def match_account():
  40. """
  41. 匹配小程序
  42. :return:
  43. """
  44. params = await request.get_json()
  45. MA = ArticleMatchAccount(params=params)
  46. res = MA.deal()
  47. return jsonify(res)
  48. @bp.route("/getShareCard", methods=["POST"])
  49. async def get_share_cards():
  50. """
  51. 获取分享卡片
  52. :return:
  53. """
  54. params = await request.get_json()
  55. SC = ShareCard(params=params)
  56. response = SC.deal()
  57. return jsonify(response)
  58. @bp.route("/singleVideo", methods=["POST"])
  59. async def find_video_info():
  60. """
  61. 获取单个视频的信息
  62. :return:
  63. """
  64. params = await request.get_json()
  65. SV = SingleVideo(params=params)
  66. response = SV.deal()
  67. return jsonify(response)
  68. @bp.route("/matchArticleV1", methods=["POST"])
  69. async def match_article():
  70. """
  71. 匹配视频
  72. :return:
  73. """
  74. params = await request.get_json()
  75. MA = MatchArticlesV1(params=params, mysql_client=mysql_client)
  76. response = await MA.deal()
  77. return jsonify(response)
  78. @bp.route("/matchArticleV2", methods=["POST"])
  79. async def recall_article():
  80. """
  81. Recall Article
  82. """
  83. params = await request.get_json()
  84. MA2 = MatchArticlesV2(params=params, mysql_client=mysql_client)
  85. response = await MA2.deal()
  86. return jsonify(response)
  87. return bp