mirror of
https://github.com/KnugiHK/WhatsApp-Chat-Exporter.git
synced 2026-04-27 16:24:53 +00:00
Also make vcard path dynamic in Android
This commit is contained in:
@@ -558,14 +558,14 @@ def vcard(db, data, media_folder):
|
|||||||
rows = c.fetchall()
|
rows = c.fetchall()
|
||||||
total_row_number = len(rows)
|
total_row_number = len(rows)
|
||||||
print(f"\nProcessing vCards...(0/{total_row_number})", end="\r")
|
print(f"\nProcessing vCards...(0/{total_row_number})", end="\r")
|
||||||
base = "WhatsApp/vCards"
|
path = f"{media_folder}/vCards"
|
||||||
if not os.path.isdir(base):
|
if not os.path.isdir(path):
|
||||||
Path(base).mkdir(parents=True, exist_ok=True)
|
Path(path).mkdir(parents=True, exist_ok=True)
|
||||||
for index, row in enumerate(rows):
|
for index, row in enumerate(rows):
|
||||||
media_name = row["media_name"] if row["media_name"] is not None else ""
|
media_name = row["media_name"] if row["media_name"] is not None else ""
|
||||||
file_name = "".join(x for x in media_name if x.isalnum())
|
file_name = "".join(x for x in media_name if x.isalnum())
|
||||||
file_name = file_name.encode('utf-8')[:230].decode('utf-8', 'ignore')
|
file_name = file_name.encode('utf-8')[:230].decode('utf-8', 'ignore')
|
||||||
file_path = os.path.join(base, f"{file_name}.vcf")
|
file_path = os.path.join(path, f"{file_name}.vcf")
|
||||||
if not os.path.isfile(file_path):
|
if not os.path.isfile(file_path):
|
||||||
with open(file_path, "w", encoding="utf-8") as f:
|
with open(file_path, "w", encoding="utf-8") as f:
|
||||||
f.write(row["vcard"])
|
f.write(row["vcard"])
|
||||||
|
|||||||
Reference in New Issue
Block a user