コード例 #1
0
def get_filename(conn, contact_conn, chat_id):
	c = conn.cursor()
	c.execute("SELECT handle_id FROM chat_handle_join WHERE chat_id=?;", (chat_id,))
	names_in_chat = []
	for row in c:
		names_in_chat.append(get_contact_name(conn, contact_conn, row[0]))
	filename = sanitize_filename(" & ".join(names_in_chat))
	file_path = os.path.join(OUTPUT_DIR, '%s.html' % filename)
	file_path = find_nonexisting_path(file_path)
	return file_path
コード例 #2
0
def output_contact(conn, backup_extractor, is_group, contact_id, contact_name,
                   your_name):
    reset_colors()
    file_path = os.path.join(OUTPUT_DIR,
                             '%s.html' % sanitize_filename(contact_name))
    file_path = find_nonexisting_path(file_path)
    html = open(file_path, 'w', encoding="utf-8")
    html.write(TEMPLATEBEGINNING % ("WhatsApp", ))
    c = conn.cursor()
    c.execute(
        "SELECT {} FROM ZWAMESSAGE WHERE ZFROMJID=? OR ZTOJID=?;".format(
            FIELDS), (contact_id, contact_id))
    for row in c:
        mdatetime = get_date(row[2])
        mtext = get_text(conn, backup_extractor, row)
        mtext = mtext.replace("\n", "<br>\n")
        mfrom, color = get_from(conn, is_group, contact_id, contact_name,
                                your_name, row)
        html.write((ROWTEMPLATE % (color, mdatetime, mfrom, mtext)))
    html.write(TEMPLATEEND)
    html.close()