From b5320c01e2e1c6aa774a4526fb9419970c2b045d Mon Sep 17 00:00:00 2001 From: lvtomatoj Date: Wed, 24 Jan 2024 18:55:34 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=BF=94=E5=9B=9E=E8=A7=86?= =?UTF-8?q?=E9=A2=91api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pywxdump/api/api.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/pywxdump/api/api.py b/pywxdump/api/api.py index b57664d..d20beab 100644 --- a/pywxdump/api/api.py +++ b/pywxdump/api/api.py @@ -11,7 +11,7 @@ import os import time import shutil -from flask import Flask, request, render_template, g, Blueprint, send_file, make_response, session +from flask import Flask, request, render_template, g, Blueprint, send_file, make_response, session,send_file from pywxdump import analyzer, read_img_dat, read_audio, get_wechat_db, get_core_db from pywxdump.api.rjson import ReJson, RqJson from pywxdump.api.utils import read_session, save_session, error9999 @@ -248,7 +248,25 @@ def get_img(): return ReJson(0, out_bytes) else: return ReJson(1001, body=img_path_all) + +@api.route('/api/video/', methods=["GET", 'POST']) +def get_video(videoPath): + # savePath = request.args.get("savePath") + # savePath = request.json.get("savePath", savePath) + savePath = "video/" + videoPath # 这个是从url中获取的 + wx_path = read_session(g.sf, "wx_path") + video_path = os.path.join(wx_path, videoPath) + if not savePath: + return ReJson(1002) + # 判断savePath路径的文件夹是否存在 + savePath = os.path.join(g.tmp_path, savePath) + if not os.path.exists(os.path.dirname(savePath)): + os.makedirs(os.path.dirname(savePath)) + + + shutil.copy(video_path, savePath) + return send_file(savePath) @api.route('/api/audio/', methods=["GET", 'POST']) def get_audio(savePath):