Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
KnugiHK committed May 9, 2022
2 parents 07cc0f3 + 60e1e7d commit 507e88d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Whatsapp_Chat_Exporter/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.8.1"
__version__ = "0.8.2"
9 changes: 8 additions & 1 deletion Whatsapp_Chat_Exporter/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -167,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 "
Expand Down
10 changes: 6 additions & 4 deletions Whatsapp_Chat_Exporter/extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -414,20 +415,21 @@ 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"
data[row[1]]["messages"][row[0]]["meta"] = True
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"
Expand Down
2 changes: 1 addition & 1 deletion Whatsapp_Chat_Exporter/extract_iphone.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 507e88d

Please sign in to comment.