From cdfaf69f7ad8a2edd6c55a816a27fe971b9d75e8 Mon Sep 17 00:00:00 2001 From: KnugiHK <24708955+KnugiHK@users.noreply.github.com> Date: Sat, 25 Mar 2023 18:26:03 +0800 Subject: [PATCH] Add an option to disable html output --- Whatsapp_Chat_Exporter/__main__.py | 33 +++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/Whatsapp_Chat_Exporter/__main__.py b/Whatsapp_Chat_Exporter/__main__.py index 38c74da..d9d6164 100644 --- a/Whatsapp_Chat_Exporter/__main__.py +++ b/Whatsapp_Chat_Exporter/__main__.py @@ -6,7 +6,7 @@ from Whatsapp_Chat_Exporter import extract from Whatsapp_Chat_Exporter import extract_iphone from Whatsapp_Chat_Exporter import extract_iphone_media from Whatsapp_Chat_Exporter.data_model import ChatStore -from Whatsapp_Chat_Exporter.extract import Crypt +from Whatsapp_Chat_Exporter.utility import Crypt from argparse import ArgumentParser import os import sqlite3 @@ -69,7 +69,8 @@ def main(): dest='json', nargs='?', default=None, - type=str, const="result.json", + type=str, + const="result.json", help="Save the result to a single JSON file (default if present: result.json)") parser.add_argument( '-d', @@ -129,6 +130,13 @@ def main(): default=None, help="Maximum size of a single output file in bytes, 0 for auto (not yet implemented)" ) + parser.add_argument( + "--no-html", + dest="no_html", + default=False, + action='store_true', + help="Do not output html files" + ) args = parser.parse_args() if args.android and args.iphone: @@ -137,6 +145,10 @@ def main(): if not args.android and not args.iphone: print("You must define the device type.") exit(1) + if args.no_html and not args.json: + print("You must either specify a JSON output file or enable HTML output.") + exit(1) + data = {} if args.android: @@ -217,14 +229,15 @@ def main(): messages(db, data) media(db, data, args.media) vcard(db, data) - create_html( - data, - args.output, - args.template, - args.embedded, - args.offline, - args.size - ) + if not args.no_html: + create_html( + data, + args.output, + args.template, + args.embedded, + args.offline, + args.size + ) else: print( "The message database does not exist. You may specify the path "