mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-12-08 20:48:48 +00:00
Validating song-info on add by api
This commit is contained in:
@@ -13,7 +13,7 @@ function get_correct_info(song_generated, channel, broadcast) {
|
|||||||
type: "GET",
|
type: "GET",
|
||||||
url: "https://www.googleapis.com/youtube/v3/videos?part=contentDetails,snippet,id&key="+key+"&id=" + song_generated.id,
|
url: "https://www.googleapis.com/youtube/v3/videos?part=contentDetails,snippet,id&key="+key+"&id=" + song_generated.id,
|
||||||
|
|
||||||
}, function(error, response, body) {
|
}, function(error, response, body, callback) {
|
||||||
try {
|
try {
|
||||||
var resp = JSON.parse(body);
|
var resp = JSON.parse(body);
|
||||||
if(resp.items.length == 1) {
|
if(resp.items.length == 1) {
|
||||||
@@ -39,6 +39,9 @@ function get_correct_info(song_generated, channel, broadcast) {
|
|||||||
if(broadcast && docs.nModified == 1) {
|
if(broadcast && docs.nModified == 1) {
|
||||||
song_generated.new_id = song_generated.id;
|
song_generated.new_id = song_generated.id;
|
||||||
io.to(channel).emit("channel", {type: "changed_values", value: song_generated});
|
io.to(channel).emit("channel", {type: "changed_values", value: song_generated});
|
||||||
|
if(callback) {
|
||||||
|
callback();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -437,8 +437,9 @@ router.route('/api/list/:channel_name/:video_id').post(function(req,res) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function postEnd(channel_name, configs, new_song, guid, res) {
|
function postEnd(channel_name, configs, new_song, guid, res) {
|
||||||
io.to(channel_name).emit("conf", configs);
|
if(configs != undefined) {
|
||||||
io.to(channel_name).emit("channel", {type: "added", value: new_song});
|
io.to(channel_name).emit("conf", configs);
|
||||||
|
}
|
||||||
List.getNextSong(channel_name, function() {
|
List.getNextSong(channel_name, function() {
|
||||||
db.collection("timeout_api").update({type: "POST", guid: guid}, {
|
db.collection("timeout_api").update({type: "POST", guid: guid}, {
|
||||||
$set: {
|
$set: {
|
||||||
@@ -447,9 +448,11 @@ function postEnd(channel_name, configs, new_song, guid, res) {
|
|||||||
guid: guid,
|
guid: guid,
|
||||||
},
|
},
|
||||||
}, {upsert: true}, function(err, docs) {
|
}, {upsert: true}, function(err, docs) {
|
||||||
res.header({'Content-Type': 'application/json'});
|
Search.get_correct_info(new_song, channel_name, !new_song.now_playing, function() {
|
||||||
res.status(200).send(JSON.stringify(new_song));
|
res.header({'Content-Type': 'application/json'});
|
||||||
return;
|
res.status(200).send(JSON.stringify(new_song));
|
||||||
|
return;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user