diff --git a/Whatsapp_Chat_Exporter/__init__.py b/Whatsapp_Chat_Exporter/__init__.py new file mode 100644 index 0000000..ecf384a --- /dev/null +++ b/Whatsapp_Chat_Exporter/__init__.py @@ -0,0 +1 @@ +__version__ = "0.5" \ No newline at end of file diff --git a/extract.py b/Whatsapp_Chat_Exporter/extract.py similarity index 99% rename from extract.py rename to Whatsapp_Chat_Exporter/extract.py index 2d672f3..0e133d8 100644 --- a/extract.py +++ b/Whatsapp_Chat_Exporter/extract.py @@ -7,6 +7,7 @@ import os import requests import shutil import re +import pkgutil from datetime import datetime from mimetypes import MimeTypes @@ -254,7 +255,7 @@ def vcard(db, data): def create_html(data, output_folder): - templateLoader = jinja2.FileSystemLoader(searchpath="./") + templateLoader = jinja2.FileSystemLoader(searchpath=os.path.dirname(__file__)) templateEnv = jinja2.Environment(loader=templateLoader) templateEnv.globals.update(determine_day=determine_day) TEMPLATE_FILE = "whatsapp.html" diff --git a/extract_iphone.py b/Whatsapp_Chat_Exporter/extract_iphone.py similarity index 99% rename from extract_iphone.py rename to Whatsapp_Chat_Exporter/extract_iphone.py index 8c4b10c..cdb96ae 100644 --- a/extract_iphone.py +++ b/Whatsapp_Chat_Exporter/extract_iphone.py @@ -6,6 +6,7 @@ import jinja2 import os import requests import shutil +import pkgutil from datetime import datetime from mimetypes import MimeTypes @@ -206,12 +207,12 @@ def vcard(db, data): def create_html(data, output_folder): - templateLoader = jinja2.FileSystemLoader(searchpath="./") + templateLoader = jinja2.FileSystemLoader(searchpath=os.path.dirname(__file__)) templateEnv = jinja2.Environment(loader=templateLoader) templateEnv.globals.update(determine_day=determine_day) TEMPLATE_FILE = "whatsapp.html" template = templateEnv.get_template(TEMPLATE_FILE) - + total_row_number = len(data) print(f"\nCreating HTML...(0/{total_row_number})", end="\r") diff --git a/extract_iphone_media.py b/Whatsapp_Chat_Exporter/extract_iphone_media.py similarity index 93% rename from extract_iphone_media.py rename to Whatsapp_Chat_Exporter/extract_iphone_media.py index 3646b2a..ae0f2f6 100644 --- a/extract_iphone_media.py +++ b/Whatsapp_Chat_Exporter/extract_iphone_media.py @@ -73,11 +73,17 @@ def extract_media(base_dir): if not support_encrypted: print("You don't have the dependencies to handle encrypted backup.") print("Read more about how to deal with encrypted backup:") - print("https://github.com/KnugiHK/Whatsapp-Chat-Exporter/blob/main/README.md#encrypted-iphone-backup") + print("https://github.com/KnugiHK/Whatsapp-Chat-Exporter/blob/main/README.md#usage") return False password = getpass.getpass("Enter the password:") extract_encrypted(base_dir, password) else: + wts_db = os.path.join(base_dir, "7c/7c7fba66680ef796b916b067077cc246adacf01d") + if not os.path.isfile(wts_db): + print("WhatsApp database not found.") + sys.exit(1) + else: + shutil.copyfile(wts_db, "7c7fba66680ef796b916b067077cc246adacf01d") with sqlite3.connect(f"{base_dir}/Manifest.db") as manifest: c = manifest.cursor() c.execute("""SELECT count() diff --git a/whatsapp.html b/Whatsapp_Chat_Exporter/whatsapp.html similarity index 97% rename from whatsapp.html rename to Whatsapp_Chat_Exporter/whatsapp.html index 2a710f0..7bea23b 100644 --- a/whatsapp.html +++ b/Whatsapp_Chat_Exporter/whatsapp.html @@ -1,158 +1,158 @@ - - - - Whatsapp - {{ name }} - - - - -
Chat history with {{ name }}
-
-
- {% set last = {'last': 946688461.001} %} - {% for msg in msgs -%} -
- - {% if determine_day(last.last, msg.timestamp) is not none %} -
{{ determine_day(last.last, msg.timestamp) }}
- {% if last.update({'last': msg.timestamp}) %}{% endif %} - {% endif %} - {% if msg.from_me == true %} -
-
{{ msg.time }}
-
You
-
-
-
-
- {% if msg.reply is not none %} - - {% endif %} - {% if msg.media == false %} - {% filter escape %}{{ msg.data or "{This message is not supported yet}" | replace('\n', '
') }}{% endfilter %} - {% else %} - {% if "image/" in msg.mime %} - - {% elif "audio/" in msg.mime %} - - {% elif "video/" in msg.mime %} - - {% elif "/" in msg.mime %} - {The file cannot be displayed here, however it should be located at {{ msg.data }}} - {% else %} - {% filter escape %}{{ msg.data }}{% endfilter %} - {% endif %} - {% if msg.caption is not none %} -
- {{ msg.caption }} - {% endif %} - {% endif %} -
-
-
-
- {% else %} -
-
- {% if msg.sender is not none %} - {{ msg.sender }} - {% else %} - {{ name }} - {% endif %} -
-
{{ msg.time }}
-
-
-
-
-
- {% if msg.reply is not none %} - - {% endif %} - {% if msg.media == false %} - {% filter escape %}{{ msg.data or "{This message is not supported yet}" }}{% endfilter %} - {% else %} - {% if "image/" in msg.mime %} - - {% elif "audio/" in msg.mime %} - - {% elif "video/" in msg.mime %} - - {% elif "/" in msg.mime %} - {The file cannot be displayed here, however it should be located at {{ msg.data }}} - {% else %} - {% filter escape %}{{ msg.data }}{% endfilter %} - {% endif %} - {% if msg.caption is not none %} -
- {{ msg.caption }} - {% endif %} - {% endif %} -
-
-
- {% endif %} -
- {% endfor %} -
-
- - + + + + Whatsapp - {{ name }} + + + + +
Chat history with {{ name }}
+
+
+ {% set last = {'last': 946688461.001} %} + {% for msg in msgs -%} +
+ + {% if determine_day(last.last, msg.timestamp) is not none %} +
{{ determine_day(last.last, msg.timestamp) }}
+ {% if last.update({'last': msg.timestamp}) %}{% endif %} + {% endif %} + {% if msg.from_me == true %} +
+
{{ msg.time }}
+
You
+
+
+
+
+ {% if msg.reply is not none %} + + {% endif %} + {% if msg.media == false %} + {% filter escape %}{{ msg.data or "{This message is not supported yet}" | replace('\n', '
') }}{% endfilter %} + {% else %} + {% if "image/" in msg.mime %} + + {% elif "audio/" in msg.mime %} + + {% elif "video/" in msg.mime %} + + {% elif "/" in msg.mime %} + {The file cannot be displayed here, however it should be located at {{ msg.data }}} + {% else %} + {% filter escape %}{{ msg.data }}{% endfilter %} + {% endif %} + {% if msg.caption is not none %} +
+ {{ msg.caption }} + {% endif %} + {% endif %} +
+
+
+
+ {% else %} +
+
+ {% if msg.sender is not none %} + {{ msg.sender }} + {% else %} + {{ name }} + {% endif %} +
+
{{ msg.time }}
+
+
+
+
+
+ {% if msg.reply is not none %} + + {% endif %} + {% if msg.media == false %} + {% filter escape %}{{ msg.data or "{This message is not supported yet}" }}{% endfilter %} + {% else %} + {% if "image/" in msg.mime %} + + {% elif "audio/" in msg.mime %} + + {% elif "video/" in msg.mime %} + + {% elif "/" in msg.mime %} + {The file cannot be displayed here, however it should be located at {{ msg.data }}} + {% else %} + {% filter escape %}{{ msg.data }}{% endfilter %} + {% endif %} + {% if msg.caption is not none %} +
+ {{ msg.caption }} + {% endif %} + {% endif %} +
+
+
+ {% endif %} +
+ {% endfor %} +
+
+ + \ No newline at end of file diff --git a/group.png b/group.png deleted file mode 100644 index eb8e653..0000000 Binary files a/group.png and /dev/null differ diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..3eebf2b --- /dev/null +++ b/setup.py @@ -0,0 +1,46 @@ +import setuptools +from re import search + +with open("README.md", "r") as fh: + long_description = fh.read() + +with open("Whatsapp_Chat_Exporter/__init__.py", encoding="utf8") as f: + version = search(r'__version__ = "(.*?)"', f.read()).group(1) + +setuptools.setup( + name="whatsapp-chat-exporter", + version=version, + author="KnugiHK", + author_email="info@knugi.com", + description="A Whatsapp database parser that will give you the history of your Whatsapp conversations in HTML and JSON.", + long_description=long_description, + long_description_content_type="text/markdown", + url="https://github.com/KnugiHK/Whatsapp-Chat-Exporter", + packages=setuptools.find_packages(), + package_data = { + '': ['whatsapp.html'] + }, + classifiers=[ + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.8", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", + "Development Status :: Beta", + "Environment :: Console", + "Intended Audience :: End Users/Desktop" + "Topic :: Communications :: Chat", + "Topic :: Utilities", + "Topic :: Database" + ], + python_requires='>=3.7', + install_requires=[ + 'jinja2' + ], + entry_points={ + "console_scripts": [ + "wtsexporter = Whatsapp_Chat_Exporter.__main__:main" + ] + } +) \ No newline at end of file