Skip to content

Commit 4da72a8

Browse files
committed
fix 部分图片无法读取
1 parent a61a3e7 commit 4da72a8

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

pywxdump/api/remote_server.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
import time
1010
import shutil
1111
from collections import Counter
12-
from urllib.parse import quote
12+
from urllib.parse import quote, unquote
1313
from typing import List, Optional
1414

1515
from pydantic import BaseModel
16-
from fastapi import APIRouter, Response, Body
16+
from fastapi import APIRouter, Response, Body, Query, Request
1717
from starlette.responses import StreamingResponse, FileResponse
1818

1919
import pywxdump
@@ -23,7 +23,7 @@
2323

2424
from .export import export_csv, export_json, export_html
2525
from .rjson import ReJson, RqJson
26-
from .utils import error9999, gc, asyncError9999
26+
from .utils import error9999, gc, asyncError9999, rs_loger
2727

2828
rs_api = APIRouter()
2929

@@ -144,14 +144,14 @@ def get_msgs(wxid: str = Body(...), start: int = Body(...), limit: int = Body(..
144144

145145
@rs_api.get('/imgsrc')
146146
@asyncError9999
147-
async def get_imgsrc(src: str):
147+
async def get_imgsrc(request: Request):
148148
"""
149149
获取图片,
150150
1. 从网络获取图片,主要功能只是下载图片,缓存到本地
151151
2. 读取本地图片
152152
:return:
153153
"""
154-
imgsrc = src
154+
imgsrc = unquote(str(request.query_params).replace("src=", "", 1))
155155
if not imgsrc:
156156
return ReJson(1002)
157157
if imgsrc.startswith("FileStorage"): # 如果是本地图片文件则调用get_img
@@ -211,12 +211,12 @@ async def get_imgsrc(src: str):
211211

212212

213213
@rs_api.api_route('/video', methods=["GET", 'POST'])
214-
def get_video(src: str):
214+
def get_video(request: Request):
215215
"""
216216
获取视频
217217
:return:
218218
"""
219-
videoPath = src
219+
videoPath = unquote(str(request.query_params).replace("src=", "", 1))
220220
if not videoPath:
221221
return ReJson(1002)
222222
my_wxid = gc.get_conf(gc.at, "last")
@@ -241,12 +241,12 @@ def get_video(src: str):
241241

242242

243243
@rs_api.api_route('/audio', methods=["GET", 'POST'])
244-
def get_audio(src: str):
244+
def get_audio(request: Request):
245245
"""
246246
获取语音
247247
:return:
248248
"""
249-
savePath = src.replace("audio\\", "")
249+
savePath = unquote(str(request.query_params).replace("src=", "", 1)).replace("audio\\", "", 1)
250250
if not savePath:
251251
return ReJson(1002)
252252
my_wxid = gc.get_conf(gc.at, "last")
@@ -296,12 +296,12 @@ def get_file_info(file_path: str = Body(..., embed=True)):
296296

297297

298298
@rs_api.get('/file')
299-
def get_file(src: str):
299+
def get_file(request: Request):
300300
"""
301301
获取文件
302302
:return:
303303
"""
304-
file_path = src
304+
file_path = unquote(str(request.query_params).replace("src=", "", 1))
305305
if not file_path:
306306
return ReJson(1002)
307307
my_wxid = gc.get_conf(gc.at, "last")

0 commit comments

Comments
 (0)