diff --git a/extract.py b/extract.py index 3bb2f1a..34fbb43 100644 --- a/extract.py +++ b/extract.py @@ -45,7 +45,7 @@ total_row_number = c.fetchone()[0] print(f"Gathering messages...(0/{total_row_number})", end="\r") phone_number_re = re.compile(r"[0-9]+@s.whatsapp.net") -c.execute("""SELECT key_remote_jid, _id, key_from_me, timestamp, data, status, edit_version, thumb_image, remote_resource, media_wa_type, latitude, longitude FROM messages; """) +c.execute("""SELECT messages.key_remote_jid, messages._id, messages.key_from_me, messages.timestamp, messages.data, messages.status, messages.edit_version, messages.thumb_image, messages.remote_resource, messages.media_wa_type, messages.latitude, messages.longitude, messages_quotes.key_id as quoted, messages.key_id, messages_quotes.data FROM messages LEFT JOIN messages_quotes ON messages.quoted_row_id = messages_quotes._id; """) i = 0 content = c.fetchone() while content is not None: @@ -55,7 +55,8 @@ while content is not None: "from_me": bool(content[2]), "timestamp": content[3]/1000, "time": datetime.fromtimestamp(content[3]/1000).strftime("%H:%M"), - "media": False + "media": False, + "key_id": content[13] } if "-" in content[0] and content[2] == 0: if content[8] in data: @@ -66,6 +67,12 @@ while content is not None: else: data[content[0]]["messages"][content[1]]["sender"] = None + if content[12] is not None: + data[content[0]]["messages"][content[1]]["reply"] = content[12] + data[content[0]]["messages"][content[1]]["quoted_data"] = content[14] + else: + data[content[0]]["messages"][content[1]]["reply"] = None + if content[5] == 6: if "-" in content[0]: # Is Group diff --git a/whatsapp.html b/whatsapp.html index 2c7c89e..4c208c9 100644 --- a/whatsapp.html +++ b/whatsapp.html @@ -8,6 +8,7 @@ html { font-family: 'Noto Sans HK', sans-serif; font-size: 12px; + scroll-behavior: smooth; } header { position: fixed; @@ -27,96 +28,121 @@ width:500px; margin:100px auto; z-index:10; + font-size: 15px; + word-wrap: break-word; } img, video { max-width:100%; width: 70%; } + a.anchor { + display: block; + position: relative; + top: -100px; + visibility: hidden; + } + div.reply{ + font-size: 13px; + text-decoration: none; + }
Chat history with {{ name }}
-
- {% set last = {'last': 946688461.001} %} - {% for msg in msgs -%} -
- {% if determine_day(last.last, msg.timestamp) is not none %} -
{{ determine_day(last.last, msg.timestamp) }}
- {% if last.update({'last': msg.timestamp}) %}{% endif %} - {% endif %} - {% if msg.from_me == true %} -
-
{{ msg.time }}
-
You
-
-
-
-
- {% if msg.media == false %} - {% filter escape %}{{ msg.data or "{This message is not supported yet}" }}{% endfilter %} - {% else %} - {% if "image/" in msg.mime %} - - {% elif "audio/" in msg.mime %} - - {% elif "video/" in msg.mime %} - - {% elif "/" in msg.mime %} - {The file cannot be displayed here, however it should be located at {% filter escape %}{{ msg.data }}{% endfilter %}} - {% else %} - {% filter escape %}{{ msg.data }}{% endfilter %} - {% endif %} - {% endif %} -
-
-
-
- {% else %} -
-
- {% if msg.sender is not none %} - {{ msg.sender }} - {% else %} - {{ name }} - {% endif %} -
-
{{ msg.time }}
-
-
-
-
-
- {% if msg.media == false %} - {% filter escape %}{{ msg.data or "{This message is not supported yet}" }}{% endfilter %} - {% else %} - {% if "image/" in msg.mime %} - - {% elif "audio/" in msg.mime %} - - {% elif "video/" in msg.mime %} - - {% elif "/" in msg.mime %} - {The file cannot be displayed here, however it should be located at {% filter escape %}{{ msg.data }}{% endfilter %}} - {% else %} - {% filter escape %}{{ msg.data }}{% endfilter %} - {% endif %} - {% endif %} -
-
-
- {% endif %} +
+ {% set last = {'last': 946688461.001} %} + {% for msg in msgs -%} +
+ + {% if determine_day(last.last, msg.timestamp) is not none %} +
{{ determine_day(last.last, msg.timestamp) }}
+ {% if last.update({'last': msg.timestamp}) %}{% endif %} + {% endif %} + {% if msg.from_me == true %} +
+
{{ msg.time }}
+
You
- {% endfor %} +
+
+
+ {% if msg.reply is not none %} + + {% endif %} + {% if msg.media == false %} + {% filter escape %}{{ msg.data or "{This message is not supported yet}" | replace('\n', '
') }}{% endfilter %} + {% else %} + {% if "image/" in msg.mime %} + + {% elif "audio/" in msg.mime %} + + {% elif "video/" in msg.mime %} + + {% elif "/" in msg.mime %} + {The file cannot be displayed here, however it should be located at {% filter escape %}{{ msg.data }}{% endfilter %}} + {% else %} + {% filter escape %}{{ msg.data }}{% endfilter %} + {% endif %} + {% endif %} +
+
+
+
+ {% else %} +
+
+ {% if msg.sender is not none %} + {{ msg.sender }} + {% else %} + {{ name }} + {% endif %} +
+
{{ msg.time }}
+
+
+
+
+
+ {% if msg.reply is not none %} + + {% endif %} + {% if msg.media == false %} + {% filter escape %}{{ msg.data or "{This message is not supported yet}" }}{% endfilter %} + {% else %} + {% if "image/" in msg.mime %} + + {% elif "audio/" in msg.mime %} + + {% elif "video/" in msg.mime %} + + {% elif "/" in msg.mime %} + {The file cannot be displayed here, however it should be located at {% filter escape %}{{ msg.data }}{% endfilter %}} + {% else %} + {% filter escape %}{{ msg.data }}{% endfilter %} + {% endif %} + {% endif %} +
+
+
+ {% endif %}
+ {% endfor %} +