From df67a549c036b5b9f679b27ec1113e16d0d8fc9c Mon Sep 17 00:00:00 2001 From: KnugiHK <24708955+KnugiHK@users.noreply.github.com> Date: Wed, 11 Sep 2024 00:23:13 +0800 Subject: [PATCH] Bug fix on empty contact list when using --enrich-from-vcards --- Whatsapp_Chat_Exporter/vcards_contacts.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Whatsapp_Chat_Exporter/vcards_contacts.py b/Whatsapp_Chat_Exporter/vcards_contacts.py index 705b016..ea38371 100644 --- a/Whatsapp_Chat_Exporter/vcards_contacts.py +++ b/Whatsapp_Chat_Exporter/vcards_contacts.py @@ -33,11 +33,16 @@ def read_vcards_file(vcf_file_path, default_country_code: str): with open(vcf_file_path, mode="r", encoding="utf-8") as f: reader = vobject.readComponents(f) for row in reader: - if not hasattr(row, 'fn') or not hasattr(row, 'tel'): + if hasattr(row, 'fn'): + name = str(row.fn.value) + elif hasattr(row, 'n'): + name = str(row.n.value) + else: + name = None + if not hasattr(row, 'tel') or name is None: continue - contact: ExportedContactNumbers = { - "full_name": row.fn.value, + "full_name": name, "numbers": list(map(lambda tel: tel.value, row.tel_list)), } contacts.append(contact)