fix 部分表情无法显示
This commit is contained in:
parent
8843c044ad
commit
ec0d4ec24e
@ -45,6 +45,7 @@ def init_last_local_wxid():
|
|||||||
return ReJson(0, {"local_wxids": local_wxid})
|
return ReJson(0, {"local_wxids": local_wxid})
|
||||||
return ReJson(0, {"local_wxids": []})
|
return ReJson(0, {"local_wxids": []})
|
||||||
|
|
||||||
|
|
||||||
@api.route('/api/init_last', methods=["GET", 'POST'])
|
@api.route('/api/init_last', methods=["GET", 'POST'])
|
||||||
@error9999
|
@error9999
|
||||||
def init_last():
|
def init_last():
|
||||||
@ -322,8 +323,11 @@ def get_imgsrc(imgsrc):
|
|||||||
if not imgsrc:
|
if not imgsrc:
|
||||||
return ReJson(1002)
|
return ReJson(1002)
|
||||||
|
|
||||||
|
if imgsrc.startswith("FileStorage"): # 如果是本地图片文件则调用get_img
|
||||||
|
return get_img(imgsrc)
|
||||||
|
|
||||||
# 将?后面的参数连接到imgsrc
|
# 将?后面的参数连接到imgsrc
|
||||||
imgsrc = imgsrc + "?" + request.query_string.decode("utf-8")
|
imgsrc = imgsrc + "?" + request.query_string.decode("utf-8") if request.query_string else imgsrc
|
||||||
|
|
||||||
my_wxid = read_session(g.sf, "test", "last")
|
my_wxid = read_session(g.sf, "test", "last")
|
||||||
if not my_wxid: return ReJson(1001, body="my_wxid is required")
|
if not my_wxid: return ReJson(1001, body="my_wxid is required")
|
||||||
@ -348,6 +352,37 @@ def get_imgsrc(imgsrc):
|
|||||||
return ReJson(4004, body=imgsrc)
|
return ReJson(4004, body=imgsrc)
|
||||||
|
|
||||||
|
|
||||||
|
@api.route('/api/img/<path:img_path>', methods=["GET", 'POST'])
|
||||||
|
@error9999
|
||||||
|
def get_img(img_path):
|
||||||
|
"""
|
||||||
|
获取图片
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
|
||||||
|
if not img_path:
|
||||||
|
return ReJson(1002)
|
||||||
|
|
||||||
|
my_wxid = read_session(g.sf, "test", "last")
|
||||||
|
if not my_wxid: return ReJson(1001, body="my_wxid is required")
|
||||||
|
wx_path = read_session(g.sf, my_wxid, "wx_path")
|
||||||
|
|
||||||
|
img_path = img_path.replace("\\\\", "\\")
|
||||||
|
|
||||||
|
img_tmp_path = os.path.join(g.tmp_path, my_wxid, "img")
|
||||||
|
original_img_path = os.path.join(wx_path, img_path)
|
||||||
|
if os.path.exists(original_img_path):
|
||||||
|
fomt, md5, out_bytes = dat2img(original_img_path)
|
||||||
|
imgsavepath = os.path.join(img_tmp_path, img_path + "_" + ".".join([md5, fomt]))
|
||||||
|
if not os.path.exists(os.path.dirname(imgsavepath)):
|
||||||
|
os.makedirs(os.path.dirname(imgsavepath))
|
||||||
|
with open(imgsavepath, "wb") as f:
|
||||||
|
f.write(out_bytes)
|
||||||
|
return send_file(imgsavepath)
|
||||||
|
else:
|
||||||
|
return ReJson(1001, body=original_img_path)
|
||||||
|
|
||||||
|
|
||||||
@api.route('/api/msgs', methods=["GET", 'POST'])
|
@api.route('/api/msgs', methods=["GET", 'POST'])
|
||||||
@error9999
|
@error9999
|
||||||
def get_msgs():
|
def get_msgs():
|
||||||
@ -377,38 +412,6 @@ def get_msgs():
|
|||||||
return ReJson(0, {"msg_list": msgs, "user_list": user_list})
|
return ReJson(0, {"msg_list": msgs, "user_list": user_list})
|
||||||
|
|
||||||
|
|
||||||
@api.route('/api/img/<path:img_path>', methods=["GET", 'POST'])
|
|
||||||
@error9999
|
|
||||||
def get_img(img_path):
|
|
||||||
"""
|
|
||||||
获取图片
|
|
||||||
:return:
|
|
||||||
"""
|
|
||||||
|
|
||||||
if not img_path:
|
|
||||||
return ReJson(1002)
|
|
||||||
|
|
||||||
my_wxid = read_session(g.sf, "test", "last")
|
|
||||||
if not my_wxid: return ReJson(1001, body="my_wxid is required")
|
|
||||||
wx_path = read_session(g.sf, my_wxid, "wx_path")
|
|
||||||
|
|
||||||
img_path = img_path.replace("\\\\", "\\")
|
|
||||||
|
|
||||||
img_tmp_path = os.path.join(g.tmp_path, my_wxid, "img")
|
|
||||||
original_img_path = os.path.join(wx_path, img_path)
|
|
||||||
|
|
||||||
if os.path.exists(original_img_path):
|
|
||||||
fomt, md5, out_bytes = dat2img(original_img_path)
|
|
||||||
imgsavepath = os.path.join(img_tmp_path, img_path + "_" + ".".join([md5, fomt]))
|
|
||||||
if not os.path.exists(os.path.dirname(imgsavepath)):
|
|
||||||
os.makedirs(os.path.dirname(imgsavepath))
|
|
||||||
with open(imgsavepath, "wb") as f:
|
|
||||||
f.write(out_bytes)
|
|
||||||
return send_file(imgsavepath)
|
|
||||||
else:
|
|
||||||
return ReJson(1001, body=original_img_path)
|
|
||||||
|
|
||||||
|
|
||||||
@api.route('/api/video/<path:videoPath>', methods=["GET", 'POST'])
|
@api.route('/api/video/<path:videoPath>', methods=["GET", 'POST'])
|
||||||
def get_video(videoPath):
|
def get_video(videoPath):
|
||||||
my_wxid = read_session(g.sf, "test", "last")
|
my_wxid = read_session(g.sf, "test", "last")
|
||||||
|
@ -395,8 +395,12 @@ class ParsingMSG(DatabaseBase):
|
|||||||
elif type_id == (47, 0): # 动画表情
|
elif type_id == (47, 0): # 动画表情
|
||||||
content_tmp = xml2dict(StrContent)
|
content_tmp = xml2dict(StrContent)
|
||||||
cdnurl = content_tmp.get("emoji", {}).get("cdnurl", "")
|
cdnurl = content_tmp.get("emoji", {}).get("cdnurl", "")
|
||||||
|
if not cdnurl:
|
||||||
|
DictExtra = self.get_BytesExtra(BytesExtra)
|
||||||
|
cdnurl = match_BytesExtra(DictExtra)
|
||||||
if cdnurl:
|
if cdnurl:
|
||||||
content = {"src": cdnurl, "msg": "表情"}
|
content = {"src": cdnurl, "msg": "表情"}
|
||||||
|
|
||||||
elif type_id == (48, 0): # 地图信息
|
elif type_id == (48, 0): # 地图信息
|
||||||
content_tmp = xml2dict(StrContent)
|
content_tmp = xml2dict(StrContent)
|
||||||
location = content_tmp.get("location", {})
|
location = content_tmp.get("location", {})
|
||||||
|
Loading…
Reference in New Issue
Block a user