From ab8ddb736e6a41315f03274828c962ad8baa596e Mon Sep 17 00:00:00 2001 From: LVtomatoJ Date: Tue, 30 Jan 2024 11:27:12 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=92=8C=E8=A7=86=E9=A2=91?= =?UTF-8?q?=E7=9A=84=E6=94=AF=E6=8C=81api=20(#71)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 增加视频api、获取文件信息接口 --- pywxdump/api/api.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/pywxdump/api/api.py b/pywxdump/api/api.py index 43595a0..c50928b 100644 --- a/pywxdump/api/api.py +++ b/pywxdump/api/api.py @@ -258,6 +258,27 @@ def get_video(videoPath): return ReJson(5002) return send_file(all_video_path) +@api.route('/api/file_info', methods=["GET", 'POST']) +def get_file_info(): + file_path = request.args.get("file_path") + file_path = request.json.get("file_path", file_path) + if not file_path: + return ReJson(1002) + wx_path = read_session(g.sf, "wx_path") + all_file_path = os.path.join(wx_path, file_path) + if not os.path.exists(all_file_path): + return ReJson(5002) + file_name = os.path.basename(all_file_path) + file_size = os.path.getsize(all_file_path) + return ReJson(0, {"file_name": file_name, "file_size": str(file_size)}) + +@api.route('/api/file/', methods=["GET", 'POST']) +def get_file(filePath): + wx_path = read_session(g.sf, "wx_path") + all_file_path = os.path.join(wx_path, filePath) + if not os.path.exists(all_file_path): + return ReJson(5002) + return send_file(all_file_path) @api.route('/api/audio/', methods=["GET", 'POST']) def get_audio(savePath):