jontv
Version:
Get info using JonTV API!
68 lines • 1.52 kB
JavaScript
var request = require('ajax-request');
function getJTVideo(id, callback) {
if(!id) return console.log('no ID provided');
if(!callback) return console.log("can't callback..");
request({
url: 'https://JonTV.me/getvideo',
method: 'GET',
data: {
v: id
}
}, function(err, res, body) {
if(err) {
return callback(err);
}
return callback(body);
});
}
getJTVideo.getuser = function(id, callback) {
if(!id) return console.log('no ID provided');
if(!callback) return console.log("can't callback..");
request({
url: 'https://JonTV.me/getuser',
method: 'GET',
data: {
id: id
}
}, function(err, res, body) {
if(err) {
return callback(err);
}
return callback(body);
});
}
getJTVideo.search = function(search, callback) {
if(!callback) return console.log("can't callback..");
if(!search) return callback(false);
request({
url: 'https://JonTV.me/s_',
method: 'GET',
data: {
q: search,
type: 'json'
}
}, function(err, res, body) {
if(err) {
return callback(err);
}
return callback(body);
});
}
getJTVideo.latestVideos = function(time, callback) {
if(!callback) return console.log("can't callback..");
let data = {
type: 'json'
}
if(time) data = {type: 'json', time: time};
request({
url: 'https://JonTV.me/getvideos',
method: 'GET',
data: data
}, function(err, res, body) {
if(err) {
return callback(err);
}
return callback(body);
});
}
module.exports = getJTVideo;