From eb5066f74ac4632b852a04491a1cbc3eb42b784e Mon Sep 17 00:00:00 2001 From: Yuxin Wu Date: Tue, 6 Sep 2016 02:01:32 -0400 Subject: [PATCH] bug fix --- README.md | 11 +++++------ wechat/parser.py | 15 ++++++++------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index b6d7d6e..bd3d10d 100644 --- a/README.md +++ b/README.md @@ -73,12 +73,12 @@ Note that commands involving `./android-interact.sh` are meant to be run on the Also, if the decryption doesn't work with pysqlcipher, maybe try the version of sqlcipher in `legacy`. -+ Copy the WeChat user resource directory `/mnt/sdcard/tencent/MicroMsg/${userid}/{emoji,image2,sfs,video,voice2}` from the phone's SD card to the `resource` directory: ++ Copy the WeChat user resource directory `/mnt/sdcard/tencent/MicroMsg/${userid}/{emoji,image2,sfs,video,voice2}` from the phone to the `resource` directory: + `./android-interact.sh res` + You might need to change `RES_DIR` in the script if the default is incorrect on your phone. + This can take a __very long__ time. Some manual ways to do it faster: - + If there's enough free space on your phone, you can archive all required files via `busybox tar` with or without compression in `adb shell`, - and use `adb pull` to copy the archive. Note that busyBox is needed as the Android system's `tar` may choke on long paths. + + If there's enough free space on your phone, you can log in and archive all required files via `busybox tar` with or without compression, + and use `adb pull` to copy the archive. Note that busybox is needed as the Android system's `tar` may choke on long paths. + Alternatively, you can use pipes. This is slower, but doesn't require any free space on your phone. ```sh # This will copy the whole 'MicroMsg' to the current directory: @@ -89,8 +89,8 @@ Note that commands involving `./android-interact.sh` are meant to be run on the + What you'll need in the end is a `resource` directory with the following subdir: `emoji,image2,sfs,video,voice2`. -+ (Optional) Download uncompress the emoji cache from [here](https://github.com/ppwwyyxx/wechat-dump/releases/download/0.1/emoji.cache.tar.bz2) - and put it under `resource/emoji`. This will avoid downloading lots of emojis in rendering. ++ (Optional) Download the emoji cache from [here](https://github.com/ppwwyyxx/wechat-dump/releases/download/0.1/emoji.cache.tar.bz2) + and put it under `resource/emoji`. This will avoid downloading too many emojis during rendering. wget -c https://github.com/ppwwyyxx/wechat-dump/releases/download/0.1/emoji.cache.tar.bz2 tar xf emoji.cache.tar.bz2 @@ -140,7 +140,6 @@ Screenshots of generated html: + more easy-to-use for non-programmers (GUI?) ### Donate! -Paypal: [paypal] diff --git a/wechat/parser.py b/wechat/parser.py index de80263..919d851 100644 --- a/wechat/parser.py +++ b/wechat/parser.py @@ -11,7 +11,7 @@ from datetime import datetime import logging logger = logging.getLogger(__name__) -from .msg import WeChatMsg +from .msg import WeChatMsg, TYPE_SYSTEM from common.textutil import ensure_unicode """ tables in concern: @@ -135,13 +135,14 @@ SELECT {} FROM message if values['chat'].endswith('@chatroom'): values['chat'] = self.contacts[values['chat']] content = values['content'] - talker = content[:content.find(':')] - try: - values['talker'] = self.contacts[talker] + if values['isSend'] == 1: + values['talker'] = self.username + elif values['type'] == TYPE_SYSTEM: + values['talker'] = u'SYSTEM' + else: + talker = content[:content.find(':')] + values['talker'] = self.contacts.get(talker, talker) values['content'] = content[content.find('\n') + 1:] - except KeyError: - # system messages have no talker - values['talker'] = u'' else: tk_id = values['talker'] values['chat'] = self.contacts[tk_id]