From 4a5cefbcd176efd95b2e255774c6ff353ad6c793 Mon Sep 17 00:00:00 2001 From: ppwwyyxx Date: Sun, 19 Apr 2015 17:32:54 +0800 Subject: [PATCH] add encryption in todo --- README.md | 1 + wechat/res.py | 33 ++++++++++++++++++++------------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 378fcfc..0c94805 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,7 @@ Screenshots: ![byvoid](https://github.com/ppwwyyxx/wechat-dump/raw/master/screenshots/byvoid.jpg) ### TODO ++ (IMPORTANT) Audio file encryption method for latest version of wechat. + Export all messages to libchat, and render messages from libchat + Search by uid/username + Skip existing files when copying android resources diff --git a/wechat/res.py b/wechat/res.py index 6bed582..46fd5ca 100644 --- a/wechat/res.py +++ b/wechat/res.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # -*- coding: UTF-8 -*- # File: res.py -# Date: Fri Mar 27 23:42:16 2015 +0800 +# Date: Sun Apr 19 17:11:07 2015 +0800 # Author: Yuxin Wu import glob @@ -33,20 +33,24 @@ JPEG_QUALITY = 50 def do_get_voice_mp3(amr_fpath): """ return base64 string, and voice duration""" - if not amr_fpath: return "", 0 - mp3_file = os.path.join('/tmp', - os.path.basename(amr_fpath)[:-4] + '.mp3') + try: + if not amr_fpath: return "", 0 + mp3_file = os.path.join('/tmp', + os.path.basename(amr_fpath)[:-4] + '.mp3') - infile = pysox.CSoxStream(amr_fpath) - outfile = pysox.CSoxStream(mp3_file, 'w', infile.get_signal()) - chain = pysox.CEffectsChain(infile, outfile) - chain.flow_effects() - outfile.close() + infile = pysox.CSoxStream(amr_fpath) + outfile = pysox.CSoxStream(mp3_file, 'w', infile.get_signal()) + chain = pysox.CEffectsChain(infile, outfile) + chain.flow_effects() + outfile.close() - signal = infile.get_signal().get_signalinfo() - duration = signal['length'] * 1.0 / signal['rate'] - mp3_string = get_file_b64(mp3_file) - os.unlink(mp3_file) + signal = infile.get_signal().get_signalinfo() + duration = signal['length'] * 1.0 / signal['rate'] + mp3_string = get_file_b64(mp3_file) + os.unlink(mp3_file) + except: + logger.warn("Failed to prepare voice file. Wechat changed their protocol!") + return 'fail', 0.1 return mp3_string, duration class Resource(object): @@ -90,6 +94,9 @@ class Resource(object): pool = Pool(3) self.voice_cache = [pool.apply_async(do_get_voice_mp3, (self.get_voice_filename(k),)) for k in voice_paths] +# single-threaded version, for debug + #self.voice_cache = map(do_get_voice_mp3, + #(self.get_voice_filename(k) for k in voice_paths)) def get_avatar(self, username): """ return base64 string"""