From 0bb99d59e097fa06fb0c49e2496f987190e6d61c Mon Sep 17 00:00:00 2001 From: KnugiHK <24708955+KnugiHK@users.noreply.github.com> Date: Mon, 13 Feb 2023 16:08:21 +0800 Subject: [PATCH] Prepare for size control of output file --- Whatsapp_Chat_Exporter/__main__.py | 32 +++++++++++++++++++++------ Whatsapp_Chat_Exporter/extract_new.py | 9 +++++++- 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/Whatsapp_Chat_Exporter/__main__.py b/Whatsapp_Chat_Exporter/__main__.py index b3e6cbc..7df3851 100644 --- a/Whatsapp_Chat_Exporter/__main__.py +++ b/Whatsapp_Chat_Exporter/__main__.py @@ -86,34 +86,45 @@ def main(): "--template", dest="template", default=None, - help="Path to custom HTML template") + help="Path to custom HTML template" + ) parser.add_argument( "-e", "--embedded", dest="embedded", default=False, action='store_true', - help="Embed media into HTML file") + help="Embed media into HTML file (not yet implemented)" + ) parser.add_argument( "-s", "--showkey", dest="showkey", default=False, action='store_true', - help="Show the HEX key used to decrypt the database") + help="Show the HEX key used to decrypt the database" + ) parser.add_argument( "-c", "--move-media", dest="move_media", default=False, action='store_true', - help="Move the media directory to output directory if the flag is set, otherwise copy it") + help="Move the media directory to output directory if the flag is set, otherwise copy it" + ) parser.add_argument( "--offline", dest="offline", - default=None, - help="Relative path to offline static files") + help="Relative path to offline static files" + ) + parser.add_argument( + "--size", + "--output-size", + dest="size", + default=None, + help="Maximum size of a single output file in bytes (not yet implemented)" + ) args = parser.parse_args() if args.android and args.iphone: @@ -199,7 +210,14 @@ def main(): messages(db, data) media(db, data, args.media) vcard(db, data) - create_html(data, args.output, args.template, args.embedded, args.offline) + 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 " diff --git a/Whatsapp_Chat_Exporter/extract_new.py b/Whatsapp_Chat_Exporter/extract_new.py index f8a58cf..22d0c69 100644 --- a/Whatsapp_Chat_Exporter/extract_new.py +++ b/Whatsapp_Chat_Exporter/extract_new.py @@ -458,7 +458,14 @@ def vcard(db, data): print(f"Gathering vCards...({index + 1}/{total_row_number})", end="\r") -def create_html(data, output_folder, template=None, embedded=False, offline_static=False): +def create_html( + data, + output_folder, + template=None, + embedded=False, + offline_static=False, + maximum_size=None + ): if template is None: template_dir = os.path.dirname(__file__) template_file = "whatsapp.html"