From 28c4a7b99ffb498b94b7665e21aad67f4014ee8e Mon Sep 17 00:00:00 2001 From: KnugiHK <24708955+KnugiHK@users.noreply.github.com> Date: Fri, 4 Mar 2022 14:03:15 +0800 Subject: [PATCH 1/5] Prepare for new function --- Whatsapp_Chat_Exporter/__main__.py | 7 +++++++ Whatsapp_Chat_Exporter/extract.py | 2 +- Whatsapp_Chat_Exporter/extract_iphone.py | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Whatsapp_Chat_Exporter/__main__.py b/Whatsapp_Chat_Exporter/__main__.py index 14a3b54..3dfa995 100644 --- a/Whatsapp_Chat_Exporter/__main__.py +++ b/Whatsapp_Chat_Exporter/__main__.py @@ -78,6 +78,13 @@ def main(): dest="template", default=None, help="Path to custom HTML template") + parser.add_option( + "-e", + "--embedded", + dest="embedded", + default=False, + action='store_true', + help="Embed media into HTML file") (options, args) = parser.parse_args() if options.android and options.iphone: diff --git a/Whatsapp_Chat_Exporter/extract.py b/Whatsapp_Chat_Exporter/extract.py index 6a94dd2..b32501a 100644 --- a/Whatsapp_Chat_Exporter/extract.py +++ b/Whatsapp_Chat_Exporter/extract.py @@ -427,7 +427,7 @@ def vcard(db, data): print(f"Gathering vCards...({index + 1}/{total_row_number})", end="\r") -def create_html(data, output_folder, template=None): +def create_html(data, output_folder, template=None, embedded=False): if template is None: template_dir = os.path.dirname(__file__) template_file = "whatsapp.html" diff --git a/Whatsapp_Chat_Exporter/extract_iphone.py b/Whatsapp_Chat_Exporter/extract_iphone.py index 66bbfc7..546be23 100644 --- a/Whatsapp_Chat_Exporter/extract_iphone.py +++ b/Whatsapp_Chat_Exporter/extract_iphone.py @@ -230,7 +230,7 @@ def vcard(db, data): print(f"Gathering vCards...({index + 1}/{total_row_number})", end="\r") -def create_html(data, output_folder, template=None): +def create_html(data, output_folder, template=None, embedded=False): if template is None: template_dir = os.path.dirname(__file__) template_file = "whatsapp.html" From 8cbb0af43a2b2bdfb35316838218cdb04ebf314c Mon Sep 17 00:00:00 2001 From: KnugiHK <24708955+KnugiHK@users.noreply.github.com> Date: Fri, 4 Mar 2022 14:06:19 +0800 Subject: [PATCH 2/5] Oh. I missed this change --- Whatsapp_Chat_Exporter/__main__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Whatsapp_Chat_Exporter/__main__.py b/Whatsapp_Chat_Exporter/__main__.py index 3dfa995..d449a91 100644 --- a/Whatsapp_Chat_Exporter/__main__.py +++ b/Whatsapp_Chat_Exporter/__main__.py @@ -174,7 +174,7 @@ def main(): messages(db, data) media(db, data, options.media) vcard(db, data) - create_html(data, options.output, options.template) + create_html(data, options.output, options.template, options.embedded) else: print( "The message database does not exist. You may specify the path " From a1319eb8358a17f225b08955301a0cd2025e9b28 Mon Sep 17 00:00:00 2001 From: KnugiHK <24708955+KnugiHK@users.noreply.github.com> Date: Fri, 1 Apr 2022 17:17:43 +0800 Subject: [PATCH 3/5] Exclude default conversation from results --- Whatsapp_Chat_Exporter/extract.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Whatsapp_Chat_Exporter/extract.py b/Whatsapp_Chat_Exporter/extract.py index b32501a..aaa9325 100644 --- a/Whatsapp_Chat_Exporter/extract.py +++ b/Whatsapp_Chat_Exporter/extract.py @@ -215,7 +215,8 @@ def messages(db, data): messages.media_caption FROM messages LEFT JOIN messages_quotes - ON messages.quoted_row_id = messages_quotes._id;""") + ON messages.quoted_row_id = messages_quotes._id + WHERE messages.key_remote_jid <> '-1';""") i = 0 content = c.fetchone() while content is not None: From 3ef3b022300b924feb4f8aced4dad2d616dff574 Mon Sep 17 00:00:00 2001 From: Aakif Aslam Date: Sun, 24 Apr 2022 18:01:32 -0400 Subject: [PATCH 4/5] Fixed bug where blank VCard media_name would crash the program. --- Whatsapp_Chat_Exporter/extract.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Whatsapp_Chat_Exporter/extract.py b/Whatsapp_Chat_Exporter/extract.py index aaa9325..6a4aab3 100644 --- a/Whatsapp_Chat_Exporter/extract.py +++ b/Whatsapp_Chat_Exporter/extract.py @@ -415,12 +415,13 @@ def vcard(db, data): if not os.path.isdir(base): Path(base).mkdir(parents=True, exist_ok=True) for index, row in enumerate(rows): - file_name = "".join(x for x in row[3] if x.isalnum()) + media_name = row[3] if row[3] else "" + file_name = "".join(x for x in media_name if x.isalnum()) file_path = f"{base}/{file_name}.vcf" if not os.path.isfile(file_path): with open(file_path, "w", encoding="utf-8") as f: f.write(row[2]) - data[row[1]]["messages"][row[0]]["data"] = row[3] + \ + data[row[1]]["messages"][row[0]]["data"] = media_name + \ "The vCard file cannot be displayed here, " \ f"however it should be located at {file_path}" data[row[1]]["messages"][row[0]]["mime"] = "text/x-vcard" From 60e1e7d3eb7da0c13e12dff98500cb8eb498769a Mon Sep 17 00:00:00 2001 From: KnugiHK <24708955+KnugiHK@users.noreply.github.com> Date: Mon, 9 May 2022 18:28:13 +0800 Subject: [PATCH 5/5] Bump version --- Whatsapp_Chat_Exporter/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Whatsapp_Chat_Exporter/__init__.py b/Whatsapp_Chat_Exporter/__init__.py index 8088f75..deded32 100644 --- a/Whatsapp_Chat_Exporter/__init__.py +++ b/Whatsapp_Chat_Exporter/__init__.py @@ -1 +1 @@ -__version__ = "0.8.1" +__version__ = "0.8.2"