Created
August 12, 2015 10:37
-
-
Save Ogreman/456237d8e69bcf3b510a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
with open('/home/user/Downloads/Takeout/Hangouts/Hangouts.json', 'r') as f: | |
s = json.load(f) | |
links = [] | |
for events in ( | |
conversation["conversation_state"]["event"] | |
for conversation in s["conversation_state"] | |
): | |
for event in events: | |
for seg in event.get("chat_message", {}).get("message_content", {}).get("segment", []): | |
if seg.get("type", "") == "LINK": | |
if seg['text'] not in links: | |
links.append(seg['text']) | |
link_map = { | |
"links": { | |
"all": list(links) | |
} | |
} | |
with open('alllinks.json', 'w') as f: | |
json.dump(link_map, f, indent=4) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment