Skip to content

Instantly share code, notes, and snippets.

@abarth500
Created December 11, 2017 04:53
Show Gist options
  • Save abarth500/e4f673ef4366523601cd4697d06b4f5d to your computer and use it in GitHub Desktop.
Save abarth500/e4f673ef4366523601cd4697d06b4f5d to your computer and use it in GitHub Desktop.
//Parameter K
var k = 30;
//need async and flickr lib
// npm install async
// npm install flickrapi
/* Internal Arguments for the algorithm A
var c = {};
var n = 0;
var T = [];
*/
function getTuple(i, finish) {
// body of the algorithms
//Call finish(null) when the procedure is finished
finish(null);
}
var async = require('async')
try {
var opt = require(__dirname + "/value.json");
} catch (err) {
if (err.code === 'MODULE_NOT_FOUND') {
try {
opt = require(__dirname + "/../../value.json");
} catch (err2) {
if (err2.code === 'MODULE_NOT_FOUND') {
console.log("Set your Flickr API key to ./values.json (See also value-original.json)");
process.exit();
}
}
}
}
var done = {};
var flickr_options = opt['flickr_options'];
var Flickr = require("flickrapi");
Flickr.tokenOnly(flickr_options, function(errFlickr, flickr) {
if (errFlickr) {
console.log("error");
} else {
async.forever(function(next) {
console.log(".");
flickr.photos.getRecent({ 'extras': 'tags' }, function(err, data) {
async.each(data.photos.photo, function(item, fin) {
if (typeof done[item.id] == 'undefined') {
done[item.id] = true;
if (item.tags != "" && item.tags.match(/^[a-zA-Z0-1\s]*$/)) {
async.each(item.tags.split(" "), function(tag, finTag) {
getTuple(tag, finTag);
}, function(err) {
fin(null);
});
} else {
fin(null);
}
} else {
fin(null);
}
}, function() {
next(null);
});
});
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment