Allow passing the user name as an argument to mine.js #1

Merged
merged 2 commits into from Mar 7, 2012
View
@@ -6,8 +6,8 @@ A simple node script that goes off to Twitter's favourite API and collects them
git clone https://github.com/remy/favs.git
cd favs
- npm install # deps
- ./mine.js # wait for full download
+ npm install # install dependencies
+ ./mine.js rem # wait for full download (replace `rem` with your username)
./cat.js # cats out all the tweets
## TODO
View
@@ -1,7 +1,8 @@
#!/usr/bin/env node
var twitterlib = require('twitterlib'), // npm install twitterlib
fs = require('fs'),
- filename = __dirname + '/favs.json';
+ filename = __dirname + '/favs.json',
+ user = process.argv[2] || 'rem';
fs.readFile(filename, 'utf8', function (e, tweetsStr) {
var options = {},
@@ -12,7 +13,7 @@ fs.readFile(filename, 'utf8', function (e, tweetsStr) {
try {
var last = JSON.parse(tweetsStr).reverse().pop();
options.since = last.id_str;
- console.log('getting tweets since ' + last.created_at);
+ console.log('getting tweets for ' + user + ' since ' + last.created_at);
offset = tweetsStr.length;
glue = ',';
} catch (e) {
@@ -28,7 +29,7 @@ fs.readFile(filename, 'utf8', function (e, tweetsStr) {
}
var data = [];
- twitterlib.favs('rem', options, function (tweets, options) {
+ twitterlib.favs(user, options, function (tweets, options) {
console.log('collected ' + tweets.length + ' tweets');
data = data.concat(tweets);
if (tweets.length) {