Yuxin Wu hace 1 año
padre
commit
20708ef755
Se han modificado 6 ficheros con 27 adiciones y 5 borrados
  1. 2 1
      android-interact.sh
  2. 1 1
      third-party/silk/Makefile
  3. 5 0
      wechat/avatar.py
  4. 6 0
      wechat/msg.py
  5. 4 1
      wechat/parser.py
  6. 9 2
      wechat/res.py

+ 2 - 1
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..."

+ 1 - 1
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))

+ 5 - 0
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)

+ 6 - 0
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

+ 4 - 1
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):

+ 9 - 2
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)