From 0341543ec9d774448ca44a04e6d6fa8f5f1ad5eb Mon Sep 17 00:00:00 2001 From: xaoyaoo Date: Sat, 13 Apr 2024 19:32:26 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E5=9B=BE=E7=89=87=E4=BC=98=E5=85=88?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E6=B8=85=E6=99=B0=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pywxdump/analyzer/export_chat.py | 9 +++++---- pywxdump/api/api.py | 12 +++++++++++- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/pywxdump/analyzer/export_chat.py b/pywxdump/analyzer/export_chat.py index b9504e9..8604b75 100644 --- a/pywxdump/analyzer/export_chat.py +++ b/pywxdump/analyzer/export_chat.py @@ -182,10 +182,11 @@ def get_msg_list(MSG_db_path, selected_talker="", start_index=0, page_size=500): elif type_id == (3, 0): # 图片 DictExtra = read_BytesExtra(BytesExtra) - DictExtra = str(DictExtra) - match = re.search(r"FileStorage(.*?)'", DictExtra) - if match: - img_path = match.group(0).replace("'", "") + DictExtra_str = str(DictExtra) + img_paths = [i for i in re.findall(r"(FileStorage.*?)'", DictExtra_str)] + img_paths = sorted(img_paths, key=lambda p: "Image" in p, reverse=True) + if img_paths: + img_path = img_paths[0].replace("'", "") img_path = [i for i in img_path.split("\\") if i] img_path = os.path.join(*img_path) content["src"] = img_path diff --git a/pywxdump/api/api.py b/pywxdump/api/api.py index fa68e44..9c7105c 100644 --- a/pywxdump/api/api.py +++ b/pywxdump/api/api.py @@ -264,7 +264,7 @@ def func_get_msgs(start, limit, wxid, msg_path, micro_path): # row_data = {"MsgSvrID": MsgSvrID, "type_name": type_name, "is_sender": IsSender, "talker": talker, # "room_name": StrTalker, "content": content, "CreateTime": CreateTime} if "merge_all" in micro_path: - contact_list = analyzer.get_contact_list(micro_path,micro_path) + contact_list = analyzer.get_contact_list(micro_path, micro_path) else: contact_list = analyzer.get_contact_list(micro_path) @@ -330,6 +330,15 @@ def get_real_time_msg(): msg_paths.sort() micro_paths = micro_paths[1] micro_paths.sort() + # for i in media_paths: + # print(i) + # merge_real_time_db(key=key, db_path=i, merge_path=save_media_path) + # for i in msg_paths: + # print(i) + # merge_real_time_db(key=key, db_path=i, merge_path=save_msg_path) + # for i in micro_paths: + # print(i) + # merge_real_time_db(key=key, db_path=i, merge_path=save_micro_path) merge_real_time_db(key=key, db_path=media_paths[-1], merge_path=save_media_path) merge_real_time_db(key=key, db_path=msg_paths[-1], merge_path=save_msg_path) merge_real_time_db(key=key, db_path=micro_paths[-1], merge_path=save_micro_path) @@ -351,6 +360,7 @@ def get_img(): return ReJson(1003, msg="Unsupported method") if not img_path: return ReJson(1002) + img_path = img_path.replace("\\\\", "\\") wx_path = read_session(g.sf, "wx_path") img_tmp_path = os.path.join(g.tmp_path, "img") img_path_all = os.path.join(wx_path, img_path)