add readme and driver
This commit is contained in:
Executable
+30
@@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env python2
|
||||
# -*- coding: UTF-8 -*-
|
||||
# File: dump_msg.py
|
||||
# Date: Fri Nov 21 14:36:23 2014 +0800
|
||||
# Author: Yuxin Wu <[email protected]>
|
||||
|
||||
from lib.Parser import WeChatDBParser
|
||||
|
||||
import sys, os
|
||||
|
||||
if len(sys.argv) != 3:
|
||||
sys.exit("Usage: {0} <path to decoded_database.db> <output_dir>".format(sys.argv[0]))
|
||||
|
||||
db_file = sys.argv[1]
|
||||
output_dir = sys.argv[2]
|
||||
try:
|
||||
os.mkdir(output_dir)
|
||||
except:
|
||||
pass
|
||||
if not os.path.isdir(output_dir):
|
||||
sys.exit("Error creating directory {}".format(output_dir))
|
||||
|
||||
parser = WeChatDBParser(db_file)
|
||||
parser.parse()
|
||||
|
||||
for name, msgs in parser.msgs_by_talker.iteritems():
|
||||
print u"Writing msgs for {}".format(name)
|
||||
with open(os.path.join(output_dir, name + '.txt'), 'w') as f:
|
||||
for m in msgs:
|
||||
print >> f, m
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env python2
|
||||
# -*- coding: UTF-8 -*-
|
||||
# File: Msg.py
|
||||
# Date: Fri Nov 21 14:08:33 2014 +0800
|
||||
# Date: Fri Nov 21 14:10:21 2014 +0800
|
||||
# Author: Yuxin Wu <[email protected]>
|
||||
|
||||
from datetime import datetime
|
||||
@@ -62,7 +62,7 @@ class WeChatMsg(object):
|
||||
self.createTime,
|
||||
ensure_unicode(self.msg_str())).encode('utf-8')
|
||||
if self.imgPath:
|
||||
ret = u"{}|img:{}".format(ensure_unicode(ret), self.imgPath)
|
||||
ret = u"{}|img:{}".format(ensure_unicode(ret.strip()), self.imgPath)
|
||||
return ret.encode('utf-8')
|
||||
else:
|
||||
return ret
|
||||
|
||||
Executable → Regular
+4
-11
@@ -1,16 +1,13 @@
|
||||
#!/usr/bin/env python2
|
||||
# -*- coding: UTF-8 -*-
|
||||
# File: dump.py
|
||||
# Date: Fri Nov 21 14:08:45 2014 +0800
|
||||
# File: Parser.py
|
||||
# Date: Fri Nov 21 14:36:18 2014 +0800
|
||||
# Author: Yuxin Wu <[email protected]>
|
||||
|
||||
import sqlite3
|
||||
from collections import defaultdict
|
||||
from pprint import PrettyPrinter
|
||||
pp = PrettyPrinter()
|
||||
def log(x): print repr(x).decode('unicode-escape')
|
||||
from lib.Msg import WeChatMsg
|
||||
from lib.utils import ensure_unicode
|
||||
from .Msg import WeChatMsg
|
||||
from .utils import ensure_unicode
|
||||
|
||||
""" tables in concern:
|
||||
emojiinfo
|
||||
@@ -71,7 +68,3 @@ SELECT {} FROM message
|
||||
def parse(self):
|
||||
self._parse_contact()
|
||||
self._parse_msg()
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = WeChatDBParser('./decoded_database.db')
|
||||
parser.parse()
|
||||
Reference in New Issue
Block a user