if __name__ == '__main__': args = get_args() name = ensure_unicode(args.name) parser = WeChatDBParser(args.db) try: chatid = parser.get_chat_id(args.name) except KeyError: sys.stderr.write(u"Valid Contacts: {}\n".format(u'\n'.join( parser.all_chat_nicknames))) sys.stderr.write(u"Couldn't find the chat {}.".format(name)) sys.exit(1) res = Resource(parser, args.res, args.avt) msgs = parser.msgs_by_chat[chatid] logger.info(f"Number of Messages for chatid {chatid}: {len(msgs)}") assert len(msgs) > 0 render = HTMLRender(parser, res) htmls = render.render_msgs(msgs) all_date_strs = [] for idx, pair in enumerate(htmls): html, date = pair date_str = date.strftime("%Y_%m_%d") all_date_strs.append(date_str) with open("pages/dates/" + date_str + '.html', 'w') as f: f.write(html)
"Usage: {0} <path to decrypted_database.db> <path to avatar.index> <path to resource> <name> <output html>" .format(sys.argv[0])) from common.textutil import ensure_unicode from wechat.parser import WeChatDBParser from wechat.res import Resource from wechat.render import HTMLRender db_file = sys.argv[1] avt_db = sys.argv[2] resource_dir = sys.argv[3] name = ensure_unicode(sys.argv[4]) output_file = sys.argv[5] parser = WeChatDBParser(db_file) res = Resource(resource_dir, avt_db) try: msgs = parser.msgs_by_talker[name] except: sys.stderr.write(u"Valid Contacts: {}\n".format(u'\n'.join( parser.msgs_by_talker.keys()))) sys.stderr.write(u"Couldn't find that contact {}.".format(name)) sys.exit(1) render = HTMLRender(parser, res) htmls = render.render_msgs(msgs) if len(htmls) == 1: with open(output_file, 'w') as f: print >> f, htmls[0].encode('utf-8')
parser.add_argument('name', help='name of contact') parser.add_argument('--output', help='output mp3 dir', default='/tmp') parser.add_argument('--db', default='decrypted.db', help='path to decrypted database') parser.add_argument('--res', default='resource', help='reseource directory') args = parser.parse_args() return args if __name__ == '__main__': args = get_args() parser = WeChatDBParser(args.db) res = Resource(parser, args.res, '') try: chatid = parser.get_chat_id(args.name) except KeyError: sys.stderr.write(u"Valid Contacts: {}\n".format('\n'.join( parser.all_chat_nicknames))) sys.stderr.write(u"Couldn't find the chat {}.".format(args.name)) sys.exit(1) msgs = parser.msgs_by_chat[chatid] print(f"Number of Messages for {args.name}: ", len(msgs)) assert len(msgs) > 0 voice_msgs = [m for m in msgs if m.type == TYPE_SPEAK] for idx, m in enumerate(voice_msgs):
help='path to decrypted database') parser.add_argument('--res', default='resource', help='reseource directory') args = parser.parse_args() return args if __name__ == '__main__': args = get_args() name = ensure_unicode(args.name) output_file = args.output parser = WeChatDBParser(args.db) res = Resource(parser, args.res, '') if name and name in parser.msgs_by_chat: msgs = parser.msgs_by_chat[name] else: sys.stderr.write(u"Valid Contacts: {}\n".format(u'\n'.join( parser.msgs_by_chat.keys()))) sys.stderr.write(u"Couldn't find that contact {}.".format(name)) sys.exit(1) print "Number of Messages: ", len(msgs) assert len(msgs) > 0 libchat = LibChatHelper(parser, res) msgs = libchat.convert_msgs(msgs) voices = [m.sound for m in msgs if m.sound] for idx, v in enumerate(voices):
sys.exit("Usage: {0} <path to decrypted_database.db> <output_dir> <res> <avt> <Group>".format(sys.argv[0])) db_file = sys.argv[1] output_dir = sys.argv[2] res_dir = sys.argv[3] avt = sys.argv[4] group = sys.argv[5] 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) res = Resource(res_dir, avt) ten_nhom = ensure_unicode(group) msgs = parser.msgs_by_chat[ten_nhom] import xlsxwriter from io import BytesIO from PIL import Image # Create a workbook and add a worksheet. workbook = xlsxwriter.Workbook('%s.xlsx' % group) worksheet = workbook.add_worksheet() worksheet.protect() worksheet.write(0, 0, "Day") worksheet.write(0, 1, "Time")
parser.add_argument('name', help='name of contact') parser.add_argument('--output', help='output html file', default='output.html') parser.add_argument('--db', default='decrypted.db', help='path to decrypted database') parser.add_argument('--avt', default='avatar.index', help='path to avatar.index file') parser.add_argument('--res', default='resource', help='reseource directory') args = parser.parse_args() return args if __name__ == '__main__': args = get_args() name = ensure_unicode(args.name) output_file = args.output parser = WeChatDBParser(args.db) res = Resource(args.res, args.avt) if name and name in parser.msgs_by_chat: msgs = parser.msgs_by_chat[name] else: sys.stderr.write(u"Valid Contacts: {}\n".format(u'\n'.join(parser.msgs_by_chat.keys()))) sys.stderr.write(u"Couldn't find that contact {}.".format(name)); sys.exit(1) print "Number of Messages: ", len(msgs) assert len(msgs) > 0 render = HTMLRender(parser, res) htmls = render.render_msgs(msgs) if len(htmls) == 1: with open(output_file, 'w') as f:
help='path to decrypted database') parser.add_argument('--res', default='resource', help='reseource directory') args = parser.parse_args() return args if __name__ == '__main__': args = get_args() name = ensure_unicode(args.name) output_file = args.output parser = WeChatDBParser(args.db) res = Resource(args.res, '') if name and name in parser.msgs_by_chat: msgs = parser.msgs_by_chat[name] else: sys.stderr.write(u"Valid Contacts: {}\n".format(u'\n'.join( parser.msgs_by_chat.keys()))) sys.stderr.write(u"Couldn't find that contact {}.".format(name)) sys.exit(1) print "Number of Messages: ", len(msgs) assert len(msgs) > 0 libchat = LibChatHelper(parser, res) msgs = libchat.convert_msgs(msgs) voices = [m.sound for m in msgs if m.sound] for idx, v in enumerate(voices):