mirror of
https://github.com/KnugiHK/WhatsApp-Chat-Exporter.git
synced 2026-05-27 19:39:02 +00:00
Automatically detect timezone offset when --time-offset is not provided #124
This commit is contained in:
@@ -12,7 +12,7 @@ from hashlib import sha256
|
|||||||
from base64 import b64decode, b64encode
|
from base64 import b64decode, b64encode
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from Whatsapp_Chat_Exporter.data_model import ChatStore, Message
|
from Whatsapp_Chat_Exporter.data_model import ChatStore, Message
|
||||||
from Whatsapp_Chat_Exporter.utility import MAX_SIZE, ROW_SIZE, DbType, convert_time_unit, determine_metadata
|
from Whatsapp_Chat_Exporter.utility import CURRENT_TZ_OFFSET, MAX_SIZE, ROW_SIZE, DbType, convert_time_unit, determine_metadata
|
||||||
from Whatsapp_Chat_Exporter.utility import rendering, Crypt, Device, get_file_name, setup_template, JidType
|
from Whatsapp_Chat_Exporter.utility import rendering, Crypt, Device, get_file_name, setup_template, JidType
|
||||||
from Whatsapp_Chat_Exporter.utility import brute_force_offset, CRYPT14_OFFSETS, get_status_location
|
from Whatsapp_Chat_Exporter.utility import brute_force_offset, CRYPT14_OFFSETS, get_status_location
|
||||||
from Whatsapp_Chat_Exporter.utility import get_chat_condition, slugify, bytes_to_readable, chat_is_empty
|
from Whatsapp_Chat_Exporter.utility import get_chat_condition, slugify, bytes_to_readable, chat_is_empty
|
||||||
@@ -354,7 +354,7 @@ def messages(db, data, media_folder, timezone_offset, filter_date, filter_chat):
|
|||||||
timestamp=content["timestamp"],
|
timestamp=content["timestamp"],
|
||||||
time=content["timestamp"],
|
time=content["timestamp"],
|
||||||
key_id=content["key_id"],
|
key_id=content["key_id"],
|
||||||
timezone_offset=timezone_offset
|
timezone_offset=timezone_offset if timezone_offset else CURRENT_TZ_OFFSET
|
||||||
)
|
)
|
||||||
if isinstance(content["data"], bytes):
|
if isinstance(content["data"], bytes):
|
||||||
message.data = ("The message is binary data and its base64 is "
|
message.data = ("The message is binary data and its base64 is "
|
||||||
@@ -717,7 +717,7 @@ def calls(db, data, timezone_offset, filter_chat):
|
|||||||
timestamp=content["timestamp"],
|
timestamp=content["timestamp"],
|
||||||
time=content["timestamp"],
|
time=content["timestamp"],
|
||||||
key_id=content["call_id"],
|
key_id=content["call_id"],
|
||||||
timezone_offset=timezone_offset
|
timezone_offset=timezone_offset if timezone_offset else CURRENT_TZ_OFFSET
|
||||||
)
|
)
|
||||||
_jid = content["raw_string"]
|
_jid = content["raw_string"]
|
||||||
name = data[_jid].name if _jid in data else content["chat_subject"] or None
|
name = data[_jid].name if _jid in data else content["chat_subject"] or None
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ from pathlib import Path
|
|||||||
from mimetypes import MimeTypes
|
from mimetypes import MimeTypes
|
||||||
from markupsafe import escape as htmle
|
from markupsafe import escape as htmle
|
||||||
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, slugify
|
from Whatsapp_Chat_Exporter.utility import APPLE_TIME, CURRENT_TZ_OFFSET, Device, get_chat_condition, slugify
|
||||||
|
|
||||||
|
|
||||||
def contacts(db, data):
|
def contacts(db, data):
|
||||||
@@ -149,7 +149,7 @@ def messages(db, data, media_folder, timezone_offset, filter_date, filter_chat):
|
|||||||
timestamp=ts,
|
timestamp=ts,
|
||||||
time=ts, # TODO: Could be bug
|
time=ts, # TODO: Could be bug
|
||||||
key_id=content["ZSTANZAID"][:17],
|
key_id=content["ZSTANZAID"][:17],
|
||||||
timezone_offset=timezone_offset
|
timezone_offset=timezone_offset if timezone_offset else CURRENT_TZ_OFFSET
|
||||||
)
|
)
|
||||||
invalid = False
|
invalid = False
|
||||||
if is_group_message and content["ZISFROMME"] == 0:
|
if is_group_message and content["ZISFROMME"] == 0:
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ except ImportError:
|
|||||||
|
|
||||||
MAX_SIZE = 4 * 1024 * 1024 # Default 4MB
|
MAX_SIZE = 4 * 1024 * 1024 # Default 4MB
|
||||||
ROW_SIZE = 0x3D0
|
ROW_SIZE = 0x3D0
|
||||||
|
CURRENT_TZ_OFFSET = datetime.now().astimezone().utcoffset().seconds / 3600
|
||||||
|
|
||||||
|
|
||||||
def convert_time_unit(time_second: int):
|
def convert_time_unit(time_second: int):
|
||||||
|
|||||||
Reference in New Issue
Block a user