mirror of
https://github.com/KnugiHK/WhatsApp-Chat-Exporter.git
synced 2026-05-30 12:58:53 +00:00
Implement separate media for iOS also
This commit is contained in:
@@ -272,8 +272,6 @@ def main():
|
|||||||
parser.error("JSON file not found.")
|
parser.error("JSON file not found.")
|
||||||
if args.android and args.business:
|
if args.android and args.business:
|
||||||
parser.error("WhatsApp Business is only available on iOS for now.")
|
parser.error("WhatsApp Business is only available on iOS for now.")
|
||||||
if args.ios and args.separate_media:
|
|
||||||
parser.error("Separate media is only available on Android for now.")
|
|
||||||
if args.json_per_chat and (
|
if args.json_per_chat and (
|
||||||
(args.json[-5:] != ".json" and os.path.isfile(args.json)) or \
|
(args.json[-5:] != ".json" and os.path.isfile(args.json)) or \
|
||||||
(args.json[-5:] == ".json" and os.path.isfile(args.json[:-5]))
|
(args.json[-5:] == ".json" and os.path.isfile(args.json[:-5]))
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import shutil
|
||||||
from glob import glob
|
from glob import glob
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from mimetypes import MimeTypes
|
from mimetypes import MimeTypes
|
||||||
from Whatsapp_Chat_Exporter.data_model import ChatStore, Message
|
from Whatsapp_Chat_Exporter.data_model import ChatStore, Message
|
||||||
from Whatsapp_Chat_Exporter.utility import APPLE_TIME, Device, get_chat_condition
|
from Whatsapp_Chat_Exporter.utility import APPLE_TIME, Device, get_chat_condition, slugify
|
||||||
|
|
||||||
|
|
||||||
def contacts(db, data):
|
def contacts(db, data):
|
||||||
@@ -256,6 +257,15 @@ def media(db, data, media_folder, filter_date, filter_chat, separate_media=False
|
|||||||
message.mime = "application/octet-stream"
|
message.mime = "application/octet-stream"
|
||||||
else:
|
else:
|
||||||
message.mime = content["ZVCARDSTRING"]
|
message.mime = content["ZVCARDSTRING"]
|
||||||
|
if separate_media:
|
||||||
|
chat_display_name = slugify(data[content["ZCONTACTJID"]].name or message.sender \
|
||||||
|
or content["ZCONTACTJID"].split('@')[0], True)
|
||||||
|
current_filename = file_path.split("/")[-1]
|
||||||
|
new_folder = os.path.join(media_folder, "separated", chat_display_name)
|
||||||
|
Path(new_folder).mkdir(parents=True, exist_ok=True)
|
||||||
|
new_path = os.path.join(new_folder, current_filename)
|
||||||
|
shutil.copy2(file_path, new_path)
|
||||||
|
message.data = new_path
|
||||||
else:
|
else:
|
||||||
if False: # Block execution
|
if False: # Block execution
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user