Fixing issue with skipping too fast

This commit is contained in:
Kasper Rynning-Tønnesen
2017-05-09 23:35:53 +02:00
parent d40fed6213
commit c426bd1da3

View File

@@ -51,8 +51,8 @@ catch(err){
cors_proxy.createServer({ cors_proxy.createServer({
requireHeader: ['origin', 'x-requested-with'], requireHeader: ['origin', 'x-requested-with'],
removeHeaders: ['cookie', 'cookie2'], removeHeaders: ['cookie', 'cookie2'],
}).listen(8081, function() { }).listen(8083, function() {
console.log('Running CORS Anywhere on :' + 8081); console.log('Running CORS Anywhere on :' + 8083);
}); });
var http = require('http'); var http = require('http');
server = http.Server(app); server = http.Server(app);
@@ -806,6 +806,7 @@ io.on('connection', function(socket){
hash = ""; hash = "";
db.collection(coll).find({views: {$exists:true}}, function(err, docs){ db.collection(coll).find({views: {$exists:true}}, function(err, docs){
if(docs !== null && docs.length !== 0) if(docs !== null && docs.length !== 0)
{ {
if(!docs[0].skip || (docs[0].adminpass == hash && docs[0].adminpass !== "") || error) if(!docs[0].skip || (docs[0].adminpass == hash && docs[0].adminpass !== "") || error)
@@ -1318,7 +1319,8 @@ function change_song(coll, error, id) {
},{multi:true}, function(err, docs){ },{multi:true}, function(err, docs){
var next_song; var next_song;
if(now_playing_doc.length == 2) next_song = now_playing_doc[1].id; if(now_playing_doc.length == 2) next_song = now_playing_doc[1].id;
if(docs.n >= 1) change_song_post(coll, next_song); //if(docs.n >= 1)
change_song_post(coll, next_song);
}); });
} }
} }
@@ -1346,13 +1348,17 @@ function change_song_post(coll, next_song)
title: 1 title: 1
} }
}, { }, {
$limit:1 $limit:2
}], function(err, docs){ }], function(err, docs){
if(docs !== null && docs.length > 0){ if(docs !== null && docs.length > 0){
var id = docs[0].id; var id = docs[0].id;
if(next_song && next_song != id) { if(next_song && next_song != id) {
if((docs.length == 2 && next_song == docs[1].id)) {
id = docs[1].id;
} else {
return; return;
} }
}
db.collection(coll).update({id:id},{ db.collection(coll).update({id:id},{
$set:{ $set:{
now_playing:true, now_playing:true,