-
Notifications
You must be signed in to change notification settings - Fork 3
/
imageInfo.js
36 lines (30 loc) · 900 Bytes
/
imageInfo.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
var sdk = require('./nitroSdk.js');
var api = require('./nitroApi/api.js');
var config = require('./config.json');
var query = sdk.newQuery();
var pid = process.argv[2];
pid = pid.replace('.jpg','');
pid = pid.replace('.png','');
query.add(api.fImagesPid,pid,true);
var host = config.nitro.host;
var path = api.nitroImages;
var key = config.nitro.api_key;
function processResults(obj){
console.log(JSON.stringify(obj.nitro.results,null,2));
}
function handleResponse(obj){
processResults(obj);
if (obj.nitro.pagination && obj.nitro.pagination.next) {
var query = sdk.newQuery();
query = query.fromString(obj.nitro.pagination.next.href,true);
sdk.make_request(host,path,key,query,{},handleResponse,function(err){
});
}
}
if (process.argv.length<3) {
console.log('Usage: imageInfo {image-pid}');
}
else {
sdk.make_request(host,path,key,query,{},handleResponse,function(err){
});
}