More RESTApi explanation in README and more endpoints

This commit is contained in:
Kasper Rynning-Tønnesen
2018-03-01 19:11:20 +01:00
parent 557bc521a5
commit 92a7c88e42
3 changed files with 454 additions and 216 deletions

View File

@@ -8,12 +8,12 @@ try {
process.exit();
}
function get_correct_info(song_generated, channel, broadcast) {
function get_correct_info(song_generated, channel, broadcast, callback) {
request({
type: "GET",
url: "https://www.googleapis.com/youtube/v3/videos?part=contentDetails,snippet,id&key="+key+"&id=" + song_generated.id,
}, function(error, response, body, callback) {
}, function(error, response, body) {
try {
var resp = JSON.parse(body);
if(resp.items.length == 1) {
@@ -39,9 +39,11 @@ function get_correct_info(song_generated, channel, broadcast) {
if(broadcast && docs.nModified == 1) {
song_generated.new_id = song_generated.id;
io.to(channel).emit("channel", {type: "changed_values", value: song_generated});
if(callback) {
if(typeof(callback) == "function") {
callback();
}
} else {
callback();
}
});
}