diff --git a/android-interact.sh b/android-interact.sh index b812541..fb39501 100755 --- a/android-interact.sh +++ b/android-interact.sh @@ -6,7 +6,8 @@ PROG_DIR=`dirname "$PROG_NAME"` cd "$PROG_DIR" # Please check that your path is the same, since this might be different among devices -RES_DIR="/mnt/sdcard/tencent/MicroMsg" +# RES_DIR="/mnt/sdcard/tencent/MicroMsg" # old version of wechat use this path. +RES_DIR="/data/data/com.tencent.mm" MM_DIR="/data/data/com.tencent.mm" echo "Starting rooted adb server..." diff --git a/third-party/silk/Makefile b/third-party/silk/Makefile index f09f9cc..8587c0f 100644 --- a/third-party/silk/Makefile +++ b/third-party/silk/Makefile @@ -47,7 +47,7 @@ ifeq (yes,$(USE_NEON)) endif -CFLAGS += -Wall -enable-threads -O3 +CFLAGS += -Wall -O3 CFLAGS += $(call cppflags-from-defines,$(CDEFINES)) CFLAGS += $(call cppflags-from-defines,$(ADDED_DEFINES)) diff --git a/wechat/avatar.py b/wechat/avatar.py index dd9d047..bd795e9 100644 --- a/wechat/avatar.py +++ b/wechat/avatar.py @@ -54,6 +54,11 @@ class AvatarReader(object): candidates = glob.glob(os.path.join(self.avt_dir, dir1, dir2, f"*{avtid}*")) candidates = sorted(set(candidates), key=_filename_priority, reverse=True) for cand in candidates: + if os.path.isdir(cand): + candidates.extend(os.path.join(cand, x) for x in os.listdir(cand)) + for cand in candidates: + if os.path.isdir(cand): + continue try: if cand.endswith(".bm"): return self.read_bm_file(cand) diff --git a/wechat/msg.py b/wechat/msg.py index e6cfbdc..c2ad547 100644 --- a/wechat/msg.py +++ b/wechat/msg.py @@ -14,6 +14,7 @@ TYPE_CUSTOM_EMOJI = 1048625 TYPE_REDENVELOPE = 436207665 TYPE_MONEY_TRANSFER = 419430449 # 微信转账 TYPE_LOCATION_SHARING = -1879048186 +TYPE_REPLY = 822083633 # 回复的消息. TYPE_APP_MSG = 16777265 _KNOWN_TYPES = [eval(k) for k in dir() if k.startswith('TYPE_')] @@ -110,6 +111,11 @@ class WeChatMsg(object): except: pass return "[Money Transfer]" + elif self.type == TYPE_REPLY: + pq = PyQuery(self.content_xml_ready) + msg = pq('title').text() + # TODO parse reply. + return msg else: # TODO replace smiley with text return self.content diff --git a/wechat/parser.py b/wechat/parser.py index ed3edb2..1d59360 100644 --- a/wechat/parser.py +++ b/wechat/parser.py @@ -74,7 +74,10 @@ SELECT {} FROM message def _parse_userinfo(self): userinfo_q = self.cc.execute(""" SELECT id, value FROM userinfo """) userinfo = dict(userinfo_q) - self.username = userinfo[2] + self.username = userinfo.get(2, None) + if self.username is None: + logger.error("Cannot find username in userinfo table!") + self.username = input("Please enter your username:") logger.info("Your username is: {}".format(self.username)) def _parse_imginfo(self): diff --git a/wechat/res.py b/wechat/res.py index 6c2fc12..0e0cc33 100644 --- a/wechat/res.py +++ b/wechat/res.py @@ -147,11 +147,18 @@ class Resource(object): if not img_file: return None if not img_file.endswith('jpg') and \ - imghdr.what(img_file) != 'jpeg': - im = Image.open(open(img_file, 'rb')) + imghdr.what(img_file) != 'jpeg': + try: + im = Image.open(open(img_file, 'rb')) + except: + return None buf = io.BytesIO() im.convert('RGB').save(buf, 'JPEG', quality=JPEG_QUALITY) return base64.b64encode(buf.getvalue()).decode('ascii') + with open(img_file, 'rb') as f: + if f.read(4) == b'wxgf': + logger.warning(f"Don't know how to decode wxgf image {img_file}") + return None return get_file_b64(img_file) big_file = get_jpg_b64(big_file)