-
-
Save jpluimers/b1912f65856b941a30bd8b21c3927382 to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env python3 | |
import os | |
import json | |
with open('tweets.js') as f: | |
tweets_str = f.read() | |
# assume the prefix is universally the same ('window.YTD.tweets.part0 = ') | |
tweets_json = json.loads(tweets_str[26:]) | |
tweets_media = [{ | |
'tweet': { | |
'id': tweet['tweet']['id'], | |
'id_str': tweet['tweet']['id_str'], | |
#'entities': tweet['tweet']['entities'], | |
'extended_entities': tweet['tweet']['extended_entities'], | |
} | |
} for tweet in tweets_json if 'media' in tweet['tweet']['entities']] | |
with open('./tweets-media.js', 'w') as f: | |
f.write('window.YTD.tweets.part0 = ') | |
f.write(json.dumps(tweets_media, indent=4)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment