Created
October 20, 2020 22:57
-
-
Save sk22/9fd5ecbcd5a7a02385d61aba7b28c1f0 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
#!/bin/sh | |
# run inside twitter-archive/data - there should be a tweet.js file | |
# this tweet.js file is meant to be read by the browser and can be | |
# a pain to import into a node.js repl. this script adds the necessary | |
# lines that let your import the tweets using a simple node require() | |
echo "const window = { YTD: { tweet: {} } }" > tweets.module.js | |
cat tweet.js >> tweets.module.js | |
echo >> tweets.module.js | |
echo "module.exports = window.YTD.tweet" >> tweets.module.js |
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
// run these commands inside a node repl | |
/* import tweets */ | |
const tweets = require('./tweets.module.js') | |
/* best tweets */ | |
console.log(tweets.part0.map(t => t.tweet) | |
.sort((o1, o2) => Number(o2.favorite_count) - Number(o1.favorite_count)) | |
.slice(0, 10) | |
.map(t => `https://twitter.com/_/status/${t.id_str}`) | |
.join('\n')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment