9
9
import time
10
10
import shutil
11
11
from collections import Counter
12
- from urllib .parse import quote
12
+ from urllib .parse import quote , unquote
13
13
from typing import List , Optional
14
14
15
15
from pydantic import BaseModel
16
- from fastapi import APIRouter , Response , Body
16
+ from fastapi import APIRouter , Response , Body , Query , Request
17
17
from starlette .responses import StreamingResponse , FileResponse
18
18
19
19
import pywxdump
23
23
24
24
from .export import export_csv , export_json , export_html
25
25
from .rjson import ReJson , RqJson
26
- from .utils import error9999 , gc , asyncError9999
26
+ from .utils import error9999 , gc , asyncError9999 , rs_loger
27
27
28
28
rs_api = APIRouter ()
29
29
@@ -144,14 +144,14 @@ def get_msgs(wxid: str = Body(...), start: int = Body(...), limit: int = Body(..
144
144
145
145
@rs_api .get ('/imgsrc' )
146
146
@asyncError9999
147
- async def get_imgsrc (src : str ):
147
+ async def get_imgsrc (request : Request ):
148
148
"""
149
149
获取图片,
150
150
1. 从网络获取图片,主要功能只是下载图片,缓存到本地
151
151
2. 读取本地图片
152
152
:return:
153
153
"""
154
- imgsrc = src
154
+ imgsrc = unquote ( str ( request . query_params ). replace ( " src=" , "" , 1 ))
155
155
if not imgsrc :
156
156
return ReJson (1002 )
157
157
if imgsrc .startswith ("FileStorage" ): # 如果是本地图片文件则调用get_img
@@ -211,12 +211,12 @@ async def get_imgsrc(src: str):
211
211
212
212
213
213
@rs_api .api_route ('/video' , methods = ["GET" , 'POST' ])
214
- def get_video (src : str ):
214
+ def get_video (request : Request ):
215
215
"""
216
216
获取视频
217
217
:return:
218
218
"""
219
- videoPath = src
219
+ videoPath = unquote ( str ( request . query_params ). replace ( " src=" , "" , 1 ))
220
220
if not videoPath :
221
221
return ReJson (1002 )
222
222
my_wxid = gc .get_conf (gc .at , "last" )
@@ -241,12 +241,12 @@ def get_video(src: str):
241
241
242
242
243
243
@rs_api .api_route ('/audio' , methods = ["GET" , 'POST' ])
244
- def get_audio (src : str ):
244
+ def get_audio (request : Request ):
245
245
"""
246
246
获取语音
247
247
:return:
248
248
"""
249
- savePath = src .replace ("audio\\ " , "" )
249
+ savePath = unquote ( str ( request . query_params ). replace ( " src=" , "" , 1 )) .replace ("audio\\ " , "" , 1 )
250
250
if not savePath :
251
251
return ReJson (1002 )
252
252
my_wxid = gc .get_conf (gc .at , "last" )
@@ -296,12 +296,12 @@ def get_file_info(file_path: str = Body(..., embed=True)):
296
296
297
297
298
298
@rs_api .get ('/file' )
299
- def get_file (src : str ):
299
+ def get_file (request : Request ):
300
300
"""
301
301
获取文件
302
302
:return:
303
303
"""
304
- file_path = src
304
+ file_path = unquote ( str ( request . query_params ). replace ( " src=" , "" , 1 ))
305
305
if not file_path :
306
306
return ReJson (1002 )
307
307
my_wxid = gc .get_conf (gc .at , "last" )
0 commit comments