-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGifferService.js
31 lines (27 loc) · 1.02 KB
/
GifferService.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
var APIService = require('./APIService');
function checkImageState(renderId, cb){
APIService.executeRequest(`http://giffer.greggernaut.com/api/v1/gif/status/${renderId}`).then(function(response){
if(response.state == 'PENDING'){
setTimeout(function(){
checkImageState(renderId, cb);
}, 1000);
} else {
cb(response);
}
})
}
exports.search = function(queryString){
return APIService.executeRequest(`http://giffer.greggernaut.com/api/v1/movie/subtitle?query=${encodeURIComponent(queryString)}`);
}
exports.requestImage = function(movieId, startSubtitleId, endSubtitleId){
return new Promise(function(resolve, reject){
APIService.executeRequest(`http://giffer.greggernaut.com/api/v1/movie/${movieId}/subtitle/${startSubtitleId}:${endSubtitleId}/mp4`).then(function(response){
checkImageState(response.renderId, function (response) {
resolve(response);
});
})
})
}
exports.getMoviePosterImageLink = function(movieId){
return APIService.executeRequest(`http://giffer.greggernaut.com/api/v1/movie/${movieId}`);
}