-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.js
49 lines (44 loc) · 1.53 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
var createClient = require("flickr-client");
var generateURLs = require("flickr-generate-urls");
var client;
module.exports = setup;
function setup (options) {
client = createClient(options);
return photo;
}
function photo (id, callback) {
client('photos.getInfo', { photo_id: id }, function (error, result) {
if (error) return callback(error);
var info = result.photo;
return callback(undefined, {
id: info.id,
title: info.title._content,
description: info.description._content,
tags: info.tags.tag,
format: info.originalformat,
url: info.urls.url[0]._content,
postTS: Number(info.dates.posted) * 1000,
takenTS: Number(new Date(info.dates.taken)),
updateTS: Number(info.dates.lastupdate) * 1000,
views: Number(info.views),
owner: {
id: info.owner.nsid,
username: info.owner.username || info.owner.path_alias,
name: info.owner.realname,
url: "https://flickr.com/photos/" + info.owner.path_alias,
icons: {
small: "https://farm" + info.owner.iconfarm + ".staticflickr.com/"+ info.owner.iconserver +"/buddyicons/"+info.owner.nsid+".jpg",
medium: "https://farm" + info.owner.iconfarm + ".staticflickr.com/"+ info.owner.iconserver +"/buddyicons/"+info.owner.nsid+"_r.jpg"
}
},
urls: generateURLs({
id: info.id,
farm: info.farm,
server: info.server,
secret: info.secret,
osecret: info.originalsecret,
format: info.originalformat
})
});
});
}