Files
wechat-dump/dump_html.py
T
2014-11-23 16:38:04 +08:00

30 lines
775 B
Python
Executable File

#!/usr/bin/env python2
# -*- coding: UTF-8 -*-
# File: dump_html.py
# Date: Sun Nov 23 16:37:48 2014 +0800
# Author: Yuxin Wu <[email protected]>
import sys
if len(sys.argv) != 5:
sys.exit("Usage: {0} <path to decrypted_database.db> <path to resource> <name> <output html>".format(sys.argv[0]))
from lib.utils import ensure_unicode
from lib.parser import WeChatDBParser
from lib.res import Resource
from lib.render import HTMLRender
db_file = sys.argv[1]
res = Resource(sys.argv[2])
name = ensure_unicode(sys.argv[3])
output_file = sys.argv[4]
parser = WeChatDBParser(db_file)
parser.parse()
msgs = parser.msgs_by_talker[name]
render = HTMLRender(parser, res)
html = render.render_msgs(msgs).encode('utf-8')
with open(output_file, 'w') as f:
print >> f, html