Skip to content

Instantly share code, notes, and snippets.

@Steffo99
Created January 9, 2019 00:16
Show Gist options
  • Save Steffo99/9d5643f964449a6e2e6eb196269ce660 to your computer and use it in GitHub Desktop.
Save Steffo99/9d5643f964449a6e2e6eb196269ce660 to your computer and use it in GitHub Desktop.
import json
import os
import re
DATA_FOLDER = "T:\\Data Takeout"
REGEX = r""
def search_inside(loaded_chat):
for msg in loaded_chat["messages"]:
match = re.search(REGEX, msg.get("content", ""), re.IGNORECASE)
if match is not None:
return match.group(0)
return None
for category in ["archived_threads", "filtered_threads", "inbox"]:
for folder in [x[0] for x in os.walk(f"{DATA_FOLDER}\\messages\\{category}\\")]:
try:
with open(f"{folder}\\message.json", "r") as file:
j = json.load(file)
except Exception:
continue
results = search_inside(j)
if results is not None:
print(f"{folder} | {results}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment