KnugiHK / WhatsApp-Chat-Exporter

A customizable Android and iOS/iPadOS WhatsApp database parser that will give you the history of your WhatsApp conversations in HTML and JSON. Android Backup Crypt12, Crypt14, Crypt15, and new schema supported.
https://wts.knugi.dev/
MIT License
518 stars 76 forks source link

contact database not found - potential fix in description #76

Open achalddave opened 7 months ago

achalddave commented 7 months ago

Thanks for this great tool! I received the following error when using this with the latest version of WhatsApp: "Contact database not found." I think the uuid(?) for the contacts db in whatsapp may have changed.

Changing this line: https://github.com/KnugiHK/WhatsApp-Chat-Exporter/blob/c27f5ee41cd97e5b954cff4dc4c08ba870be0fbf/Whatsapp_Chat_Exporter/utility.py#L299

from

    CONTACT = "b8548dc30aa1030df0ce18ef08b882cf7ab5212f"

to

    CONTACT = "016df2e52e5bfaa000f98a1dbe5c40cd6dc7f657"

fixed the issue for me. I'm not sure if this is a general fix, so I'm not submitting a PR, but opening this issue in case anyone else runs into it.

KnugiHK commented 7 months ago

I currently don't have access to the latest iOS WhatsApp. Once it has been confirmed, I will make changes to the code. Thanks for your report and the potential fix anyway!

SvenHerr commented 6 months ago

@achalddave how did you know that this is the new db ? i cant find 016df2e52e5bfaa000f98a1dbe5c40cd6dc7f657 with the version 17.2.1

achalddave commented 6 months ago

I'm sure there's a better way, but I went to the path to my Manifest.db, which was in a path like: ~/Library/Application Support/MobileSync/Backup/<numbers>/Manifest.db, and then ran:

~ sqlite3 Manifest.db
SQLite version 3.39.5 2022-10-14 20:58:05
Enter ".help" for usage hints.
sqlite> select * from files;

This printed a bunch of tables, and I looked for one which said ContactsV2.sqlite, and copied the hash at the start of that line.

KnugiHK commented 6 months ago

I'm sure there's a better way, but I went to the path to my Manifest.db, which was in a path like: ~/Library/Application Support/MobileSync/Backup/<numbers>/Manifest.db, and then ran:

~ sqlite3 Manifest.db
SQLite version 3.39.5 2022-10-14 20:58:05
Enter ".help" for usage hints.
sqlite> select * from files;

This printed a bunch of tables, and I looked for one which said ContactsV2.sqlite, and copied the hash at the start of that line.

This is the correct way to find a file inside an iOS backup.

SvenHerr commented 6 months ago

thank you for your reply. I just looked throu all files with .sqlite and i cant find any db with contacts.

Rerebla commented 6 months ago

I get the same error "Contact database not found". Running the program with the default or the suggested fix results in the same error. I couldn't find any ContactsV2 or anything containing 'contacts' related to WhatsApp (just blockedContacts.dat).

angelbanderasudg commented 5 months ago

@Rerebla The file with blockedContacts.dat was the only one that appeared, but it used it and worked.

After following the steps of searching it with sqlite3, the complete line is this: 4c6a43645ed0557e7ea2ebb662ef8a2c81b505b8|AppDomain-net.whatsapp.WhatsApp|Documents/blockedcontacts.dat|1|bplist00?

You only need the first part: 4c6a43645ed0557e7ea2ebb662ef8a2c81b505b8

The file to modify, like I have the installation of python in the default directory, the path is: /Users/your_username/Library/Python/3.9/lib/python/site-packages/Whatsapp_Chat_Exporter/utility.py

My WhatsApp version is 23.23.79

roisec commented 4 months ago

@angelbanderasudg it's solved the issue but after I have another issue Unexpected contact format: broadcast

  File "/Users//repos/iphone/lib/python3.11/site-packages/Whatsapp_Chat_Exporter/__main__.py", line 425, in main
    create_html(
  File "/Users//repos/iphone/lib/python3.11/site-packages/Whatsapp_Chat_Exporter/android_handler.py", line 753, in create_html
    safe_file_name, name = get_file_name(contact, chat)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users//repos/iphone/lib/python3.11/site-packages/Whatsapp_Chat_Exporter/utility.py", line 141, in get_file_name
    raise ValueError("Unexpected contact format: " + contact)
ValueError: Unexpected contact format: broadcast
jpfleischer commented 1 month ago

please merge @angelbanderasudg 's fix

KnugiHK commented 1 week ago

@angelbanderasudg it's solved the issue but after I have another issue Unexpected contact format: broadcast

  File "/Users//repos/iphone/lib/python3.11/site-packages/Whatsapp_Chat_Exporter/__main__.py", line 425, in main
    create_html(
  File "/Users//repos/iphone/lib/python3.11/site-packages/Whatsapp_Chat_Exporter/android_handler.py", line 753, in create_html
    safe_file_name, name = get_file_name(contact, chat)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users//repos/iphone/lib/python3.11/site-packages/Whatsapp_Chat_Exporter/utility.py", line 141, in get_file_name
    raise ValueError("Unexpected contact format: " + contact)
ValueError: Unexpected contact format: broadcast

I notice that your handler is for Android. Please open a separate issue for that as this issue exclusively appear in iOS.