mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-12-08 20:48:48 +00:00
Fixes
This commit is contained in:
@@ -6,9 +6,9 @@ var crypto = require('crypto');
|
|||||||
var Filter = require('bad-words');
|
var Filter = require('bad-words');
|
||||||
var filter = new Filter({ placeHolder: 'x'});
|
var filter = new Filter({ placeHolder: 'x'});
|
||||||
/*var filter = {
|
/*var filter = {
|
||||||
clean: function(str) {
|
clean: function(str) {
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
var db = require(pathThumbnails + '/handlers/db.js');
|
var db = require(pathThumbnails + '/handlers/db.js');
|
||||||
|
|
||||||
@@ -28,7 +28,7 @@ function addFromOtherList(arr, guid, offline, socket) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
socket.emit('update_required', result);
|
socket.emit('update_required', result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var channel = arr.channel;//.replace(/ /g,'').toLowerCase();
|
var channel = arr.channel;//.replace(/ /g,'').toLowerCase();
|
||||||
var new_channel = Functions.encodeChannelName(arr.new_channel);//.replace(/ /g, '').toLowerCase();
|
var new_channel = Functions.encodeChannelName(arr.new_channel);//.replace(/ /g, '').toLowerCase();
|
||||||
@@ -93,38 +93,41 @@ function addFromOtherList(arr, guid, offline, socket) {
|
|||||||
MongoClient.connect(url, function(err, _db) {
|
MongoClient.connect(url, function(err, _db) {
|
||||||
var dbo = _db.db(mongo_config.config);
|
var dbo = _db.db(mongo_config.config);
|
||||||
dbo.collection(channel).insertMany(docs, {ordered: false}, function(err, res) {
|
dbo.collection(channel).insertMany(docs, {ordered: false}, function(err, res) {
|
||||||
db.collection(channel + "_settings").update({id: "config"}, {$set: {startTime: Functions.get_time()}}, function(e,d) {
|
db.collection(channel).count({type: {$ne: "suggested"}}, function(err, count) {
|
||||||
if(to_set_np) {
|
db.collection(channel + "_settings").update({id: "config"}, {$set: {startTime: Functions.get_time()}}, function(e,d) {
|
||||||
var to_change = {
|
if(to_set_np) {
|
||||||
_id: channel,
|
var to_change = {
|
||||||
count: res.nInserted != undefined ? res.nInserted : res.insertedCount,
|
_id: channel,
|
||||||
frontpage: true,
|
count: count,
|
||||||
accessed: Functions.get_time(),
|
frontpage: true,
|
||||||
}
|
accessed: Functions.get_time(),
|
||||||
db.collection(channel).find({now_playing: true}, function(e, np_docs) {
|
}
|
||||||
to_change.id = np_docs[0].id;
|
db.collection(channel).find({now_playing: true}, function(e, np_docs) {
|
||||||
to_change.title = np_docs[0].title;
|
to_change.id = np_docs[0].id;
|
||||||
db.collection("frontpage_lists").find({_id: coll}, function(e, doc) {
|
to_change.title = np_docs[0].title;
|
||||||
if(doc.length > 0 && ((doc[0].thumbnail != "" && doc[0].thumbnail != undefined && (doc[0].thumbnail.indexOf("https://i1.sndcdn.com") > -1 || doc[0].thumbnail.indexOf("https://w1.sndcdn.com") > -1)) || (doc[0].thumbnail == "" || doc[0].thumbnail == undefined))) {
|
|
||||||
to_change.thumbnail = np_docs[0].thumbnail;
|
|
||||||
}
|
|
||||||
|
|
||||||
db.collection("frontpage_lists").update({_id: channel}, {$set: to_change}, function(e, d) {
|
db.collection("frontpage_lists").find({_id: coll}, function(e, doc) {
|
||||||
List.send_list(channel, undefined, false, true, false);
|
if(doc.length > 0 && ((doc[0].thumbnail != "" && doc[0].thumbnail != undefined && (doc[0].thumbnail.indexOf("https://i1.sndcdn.com") > -1 || doc[0].thumbnail.indexOf("https://w1.sndcdn.com") > -1)) || (doc[0].thumbnail == "" || doc[0].thumbnail == undefined))) {
|
||||||
List.send_play(channel, undefined);
|
to_change.thumbnail = np_docs[0].thumbnail;
|
||||||
socket.emit("toast", "addedplaylist");
|
}
|
||||||
_db.close();
|
|
||||||
|
db.collection("frontpage_lists").update({_id: channel}, {$set: to_change}, function(e, d) {
|
||||||
|
List.send_list(channel, undefined, false, true, false);
|
||||||
|
List.send_play(channel, undefined);
|
||||||
|
socket.emit("toast", "addedplaylist");
|
||||||
|
_db.close();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
} else {
|
||||||
} else {
|
db.collection("frontpage_lists").update({_id: channel}, {$set: {count: count}}, function(e, d) {
|
||||||
db.collection("frontpage_lists").update({_id: channel}, {$inc: {count: res.nInserted != undefined ? res.nInserted : res.insertedCount}}, function(e, d) {
|
List.send_list(channel, undefined, false, true, false);
|
||||||
List.send_list(channel, undefined, false, true, false);
|
List.send_play(channel, undefined);
|
||||||
List.send_play(channel, undefined);
|
socket.emit("toast", "addedplaylist");
|
||||||
socket.emit("toast", "addedplaylist");
|
_db.close();
|
||||||
_db.close();
|
})
|
||||||
})
|
}
|
||||||
}
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -166,7 +169,7 @@ function addPlaylist(arr, guid, offline, socket) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
socket.emit('update_required', result);
|
socket.emit('update_required', result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var channel = arr.channel;//.replace(/ /g,'').toLowerCase();
|
var channel = arr.channel;//.replace(/ /g,'').toLowerCase();
|
||||||
db.collection("frontpage_lists").find({_id: channel}, function(err, fp) {
|
db.collection("frontpage_lists").find({_id: channel}, function(err, fp) {
|
||||||
@@ -236,38 +239,40 @@ function addPlaylist(arr, guid, offline, socket) {
|
|||||||
bulk.insert(this_element);
|
bulk.insert(this_element);
|
||||||
}
|
}
|
||||||
bulk.execute(function(err, results) {
|
bulk.execute(function(err, results) {
|
||||||
db.collection(channel + "_settings").update({id: "config"}, {$set: {startTime: Functions.get_time()}}, function(e,d) {
|
db.collection(channel).count({type: {$ne: "suggested"}}, function(err, count) {
|
||||||
if(to_set_np) {
|
db.collection(channel + "_settings").update({id: "config"}, {$set: {startTime: Functions.get_time()}}, function(e,d) {
|
||||||
var to_change = {
|
if(to_set_np) {
|
||||||
_id: channel,
|
var to_change = {
|
||||||
count: results.nInserted,
|
_id: channel,
|
||||||
frontpage: true,
|
count: count,
|
||||||
accessed: Functions.get_time(),
|
frontpage: true,
|
||||||
}
|
accessed: Functions.get_time(),
|
||||||
db.collection(channel).find({now_playing: true}, function(e, np_docs) {
|
}
|
||||||
to_change.id = np_docs[0].id;
|
db.collection(channel).find({now_playing: true}, function(e, np_docs) {
|
||||||
to_change.title = np_docs[0].title;
|
to_change.id = np_docs[0].id;
|
||||||
db.collection("frontpage_lists").find({_id: channel}, function(e, doc) {
|
to_change.title = np_docs[0].title;
|
||||||
if(doc.length > 0 && ((doc[0].thumbnail != "" && doc[0].thumbnail != undefined && (doc[0].thumbnail.indexOf("https://i1.sndcdn.com") > -1 || doc[0].thumbnail.indexOf("https://w1.sndcdn.com") > -1)) || (doc[0].thumbnail == "" || doc[0].thumbnail == undefined))) {
|
db.collection("frontpage_lists").find({_id: channel}, function(e, doc) {
|
||||||
to_change.thumbnail = np_docs[0].thumbnail;
|
if(doc.length > 0 && ((doc[0].thumbnail != "" && doc[0].thumbnail != undefined && (doc[0].thumbnail.indexOf("https://i1.sndcdn.com") > -1 || doc[0].thumbnail.indexOf("https://w1.sndcdn.com") > -1)) || (doc[0].thumbnail == "" || doc[0].thumbnail == undefined))) {
|
||||||
}
|
to_change.thumbnail = np_docs[0].thumbnail;
|
||||||
|
}
|
||||||
|
|
||||||
db.collection("frontpage_lists").update({_id: channel}, {$set: to_change}, function(e, d) {
|
db.collection("frontpage_lists").update({_id: channel}, {$set: to_change}, function(e, d) {
|
||||||
List.send_list(channel, undefined, false, true, false);
|
List.send_list(channel, undefined, false, true, false);
|
||||||
List.send_play(channel, undefined);
|
List.send_play(channel, undefined);
|
||||||
socket.emit("toast", "addedplaylist");
|
socket.emit("toast", "addedplaylist");
|
||||||
_db.close();
|
_db.close();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
} else {
|
||||||
} else {
|
db.collection("frontpage_lists").update({_id: channel}, {$set: {count: count}}, function(e, d) {
|
||||||
db.collection("frontpage_lists").update({_id: channel}, {$inc: {count: results.nInserted != undefined ? results.nInserted : results.insertedCount}}, function(e, d) {
|
List.send_list(channel, undefined, false, true, false);
|
||||||
List.send_list(channel, undefined, false, true, false);
|
List.send_play(channel, undefined);
|
||||||
List.send_play(channel, undefined);
|
socket.emit("toast", "addedplaylist");
|
||||||
socket.emit("toast", "addedplaylist");
|
_db.close();
|
||||||
_db.close();
|
})
|
||||||
})
|
}
|
||||||
}
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -296,18 +301,18 @@ function add_function(arr, coll, guid, offline, socket) {
|
|||||||
{
|
{
|
||||||
|
|
||||||
if(coll == "" || coll == undefined || coll == null ||
|
if(coll == "" || coll == undefined || coll == null ||
|
||||||
!arr.hasOwnProperty("start") || !arr.hasOwnProperty("end")) {
|
!arr.hasOwnProperty("start") || !arr.hasOwnProperty("end")) {
|
||||||
var result = {
|
var result = {
|
||||||
start: {
|
start: {
|
||||||
expected: "number or string that can be cast to int",
|
expected: "number or string that can be cast to int",
|
||||||
got: arr.hasOwnProperty("start") ? typeof(arr.start) : undefined
|
got: arr.hasOwnProperty("start") ? typeof(arr.start) : undefined
|
||||||
},
|
},
|
||||||
end: {
|
end: {
|
||||||
expected: "number or string that can be cast to int",
|
expected: "number or string that can be cast to int",
|
||||||
got: arr.hasOwnProperty("end") ? typeof(arr.end) : undefined
|
got: arr.hasOwnProperty("end") ? typeof(arr.end) : undefined
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
socket.emit('update_required', result);
|
socket.emit('update_required', result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -332,51 +337,51 @@ function add_function(arr, coll, guid, offline, socket) {
|
|||||||
|
|
||||||
|
|
||||||
if(typeof(arr.id) != "string" || typeof(arr.start) != "number" ||
|
if(typeof(arr.id) != "string" || typeof(arr.start) != "number" ||
|
||||||
typeof(arr.end) != "number" || typeof(arr.title) != "string" ||
|
typeof(arr.end) != "number" || typeof(arr.title) != "string" ||
|
||||||
typeof(arr.list) != "string" || typeof(arr.duration) != "number" ||
|
typeof(arr.list) != "string" || typeof(arr.duration) != "number" ||
|
||||||
typeof(arr.source) != "string" ||
|
typeof(arr.source) != "string" ||
|
||||||
(arr.source == "soundcloud" && (!arr.hasOwnProperty("thumbnail") || !Functions.isUrl(arr.thumbnail)))) {
|
(arr.source == "soundcloud" && (!arr.hasOwnProperty("thumbnail") || !Functions.isUrl(arr.thumbnail)))) {
|
||||||
var result = {
|
var result = {
|
||||||
start: {
|
start: {
|
||||||
expected: "number or string that can be cast to int",
|
expected: "number or string that can be cast to int",
|
||||||
got: arr.hasOwnProperty("start") ? typeof(arr.start) : undefined
|
got: arr.hasOwnProperty("start") ? typeof(arr.start) : undefined
|
||||||
},
|
},
|
||||||
end: {
|
end: {
|
||||||
expected: "number or string that can be cast to int",
|
expected: "number or string that can be cast to int",
|
||||||
got: arr.hasOwnProperty("end") ? typeof(arr.end) : undefined
|
got: arr.hasOwnProperty("end") ? typeof(arr.end) : undefined
|
||||||
},
|
},
|
||||||
title: {
|
title: {
|
||||||
expected: "string",
|
expected: "string",
|
||||||
got: arr.hasOwnProperty("title") ? typeof(arr.title) : undefined
|
got: arr.hasOwnProperty("title") ? typeof(arr.title) : undefined
|
||||||
},
|
},
|
||||||
list: {
|
list: {
|
||||||
expected: "string",
|
expected: "string",
|
||||||
got: arr.hasOwnProperty("list") ? typeof(arr.list) : undefined
|
got: arr.hasOwnProperty("list") ? typeof(arr.list) : undefined
|
||||||
},
|
},
|
||||||
duration: {
|
duration: {
|
||||||
expected: "number or string that can be cast to int",
|
expected: "number or string that can be cast to int",
|
||||||
got: arr.hasOwnProperty("duration") ? typeof(arr.duration) : undefined
|
got: arr.hasOwnProperty("duration") ? typeof(arr.duration) : undefined
|
||||||
},
|
},
|
||||||
pass: {
|
pass: {
|
||||||
expected: "string",
|
expected: "string",
|
||||||
got: arr.hasOwnProperty("pass") ? typeof(arr.pass) : undefined
|
got: arr.hasOwnProperty("pass") ? typeof(arr.pass) : undefined
|
||||||
},
|
},
|
||||||
adminpass: {
|
adminpass: {
|
||||||
expected: "string",
|
expected: "string",
|
||||||
got: arr.hasOwnProperty("adminpass") ? typeof(arr.adminpass) : undefined
|
got: arr.hasOwnProperty("adminpass") ? typeof(arr.adminpass) : undefined
|
||||||
},
|
},
|
||||||
source: {
|
source: {
|
||||||
expected: "string (youtube or soundcloud)",
|
expected: "string (youtube or soundcloud)",
|
||||||
got: arr.hasOwnProperty("source") ? typeof(arr.source) : undefined
|
got: arr.hasOwnProperty("source") ? typeof(arr.source) : undefined
|
||||||
},
|
},
|
||||||
thumbnail: {
|
thumbnail: {
|
||||||
expected: "url if source == soundcloud",
|
expected: "url if source == soundcloud",
|
||||||
got: arr.hasOwnProperty("thumbnail") ? typeof(arr.thumbnail) : undefined
|
got: arr.hasOwnProperty("thumbnail") ? typeof(arr.thumbnail) : undefined
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
socket.emit('update_required', result);
|
socket.emit('update_required', result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//coll = coll.replace(/ /g,'');
|
//coll = coll.replace(/ /g,'');
|
||||||
Functions.getSessionAdminUser(Functions.getSession(socket), coll, function(userpass, adminpass) {
|
Functions.getSessionAdminUser(Functions.getSession(socket), coll, function(userpass, adminpass) {
|
||||||
if(adminpass != "" || arr.adminpass == undefined) {
|
if(adminpass != "" || arr.adminpass == undefined) {
|
||||||
@@ -396,73 +401,73 @@ function add_function(arr, coll, guid, offline, socket) {
|
|||||||
var source = arr.source;
|
var source = arr.source;
|
||||||
/*db.collection(coll + "_settings").find(function(err, docs)
|
/*db.collection(coll + "_settings").find(function(err, docs)
|
||||||
{*/
|
{*/
|
||||||
conf = docs;
|
conf = docs;
|
||||||
if(docs !== null && docs.length !== 0 && ((docs[0].addsongs === true && (hash == docs[0].adminpass || docs[0].adminpass === "")) ||
|
if(docs !== null && docs.length !== 0 && ((docs[0].addsongs === true && (hash == docs[0].adminpass || docs[0].adminpass === "")) ||
|
||||||
docs[0].addsongs === false)) {
|
docs[0].addsongs === false)) {
|
||||||
db.collection(coll).find({id:id, type:{$ne:"suggested"}}, function(err, docs){
|
db.collection(coll).find({id:id, type:{$ne:"suggested"}}, function(err, docs){
|
||||||
if(docs !== null && docs.length === 0) {
|
if(docs !== null && docs.length === 0) {
|
||||||
var guids = [guid];
|
var guids = [guid];
|
||||||
var added = Functions.get_time();
|
var added = Functions.get_time();
|
||||||
var votes = 1;
|
var votes = 1;
|
||||||
db.collection(coll).find({now_playing:true}, function(err, docs){
|
db.collection(coll).find({now_playing:true}, function(err, docs){
|
||||||
if((docs !== null && docs.length === 0)){
|
if((docs !== null && docs.length === 0)){
|
||||||
np = true;
|
np = true;
|
||||||
} else {
|
|
||||||
np = false;
|
|
||||||
}
|
|
||||||
var new_song = {"added": added,"guids":guids,"id":id,"now_playing":np,"title":title,"votes":votes, "duration":duration, "start": parseInt(start), "end": parseInt(end), "type": "video", "source": source};
|
|
||||||
if(source == "soundcloud") {
|
|
||||||
if(arr.thumbnail.indexOf("https://i1.sndcdn.com") > -1 || arr.thumbnail.indexOf("https://w1.sndcdn.com") > -1) {
|
|
||||||
new_song.thumbnail = arr.thumbnail;
|
|
||||||
} else {
|
|
||||||
new_song.thumbnail = "https://img.youtube.com/vi/404_notfound/mqdefault.jpg";
|
|
||||||
}
|
|
||||||
} else if(source == "youtube") new_song.thumbnail = "https://img.youtube.com/vi/" + new_song.id + "/mqdefault.jpg";
|
|
||||||
db.collection(coll).update({id: id}, new_song, {upsert: true}, function(err, docs){
|
|
||||||
new_song._id = "asd";
|
|
||||||
if(np) {
|
|
||||||
List.send_list(coll, undefined, false, true, false);
|
|
||||||
db.collection(coll + "_settings").update({ id: "config" }, {$set:{startTime: Functions.get_time()}});
|
|
||||||
List.send_play(coll, undefined);
|
|
||||||
var thumbnail = arr.thumbnail != undefined ? arr.thumbnail : undefined;
|
|
||||||
Frontpage.update_frontpage(coll, id, title, thumbnail, arr.source);
|
|
||||||
if(source != "soundcloud") Search.get_correct_info(new_song, coll, false);
|
|
||||||
} else {
|
|
||||||
io.to(coll).emit("channel", {type: "added", value: new_song});
|
|
||||||
if(source != "soundcloud") Search.get_correct_info(new_song, coll, true);
|
|
||||||
}
|
|
||||||
db.collection("frontpage_lists").update({_id:coll}, {$inc:{count:1}, $set:{accessed: Functions.get_time()}}, {upsert:true}, function(err, docs){});
|
|
||||||
List.getNextSong(coll, undefined);
|
|
||||||
});
|
|
||||||
socket.emit("toast", "addedsong");
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
vote(coll, id, guid, socket);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
db.collection(coll).find({id: id}, function(err, docs) {
|
|
||||||
if(docs.length === 0) {
|
|
||||||
var suggestedAdd = {
|
|
||||||
"added":Functions.get_time(),
|
|
||||||
"guids": [guid],
|
|
||||||
"id":id,
|
|
||||||
"now_playing": false,
|
|
||||||
"title":title,
|
|
||||||
"votes":1,
|
|
||||||
"duration":duration,
|
|
||||||
"start": start,
|
|
||||||
"end": end,
|
|
||||||
"type":"suggested"
|
|
||||||
};
|
|
||||||
var source = arr.source;
|
|
||||||
if(source == "soundcloud") {
|
|
||||||
suggestedAdd.thumbnail = arr.thumbnail;
|
|
||||||
suggestedAdd.source = source;
|
|
||||||
} else {
|
} else {
|
||||||
suggestedAdd.source = "youtube";
|
np = false;
|
||||||
}
|
}
|
||||||
db.collection(coll).update({id: id}, {$set: suggestedAdd},
|
var new_song = {"added": added,"guids":guids,"id":id,"now_playing":np,"title":title,"votes":votes, "duration":duration, "start": parseInt(start), "end": parseInt(end), "type": "video", "source": source};
|
||||||
|
if(source == "soundcloud") {
|
||||||
|
if(arr.thumbnail.indexOf("https://i1.sndcdn.com") > -1 || arr.thumbnail.indexOf("https://w1.sndcdn.com") > -1) {
|
||||||
|
new_song.thumbnail = arr.thumbnail;
|
||||||
|
} else {
|
||||||
|
new_song.thumbnail = "https://img.youtube.com/vi/404_notfound/mqdefault.jpg";
|
||||||
|
}
|
||||||
|
} else if(source == "youtube") new_song.thumbnail = "https://img.youtube.com/vi/" + new_song.id + "/mqdefault.jpg";
|
||||||
|
db.collection(coll).update({id: id}, new_song, {upsert: true}, function(err, docs){
|
||||||
|
new_song._id = "asd";
|
||||||
|
if(np) {
|
||||||
|
List.send_list(coll, undefined, false, true, false);
|
||||||
|
db.collection(coll + "_settings").update({ id: "config" }, {$set:{startTime: Functions.get_time()}});
|
||||||
|
List.send_play(coll, undefined);
|
||||||
|
var thumbnail = arr.thumbnail != undefined ? arr.thumbnail : undefined;
|
||||||
|
Frontpage.update_frontpage(coll, id, title, thumbnail, arr.source);
|
||||||
|
if(source != "soundcloud") Search.get_correct_info(new_song, coll, false);
|
||||||
|
} else {
|
||||||
|
io.to(coll).emit("channel", {type: "added", value: new_song});
|
||||||
|
if(source != "soundcloud") Search.get_correct_info(new_song, coll, true);
|
||||||
|
}
|
||||||
|
db.collection("frontpage_lists").update({_id:coll}, {$inc:{count:1}, $set:{accessed: Functions.get_time()}}, {upsert:true}, function(err, docs){});
|
||||||
|
List.getNextSong(coll, undefined);
|
||||||
|
});
|
||||||
|
socket.emit("toast", "addedsong");
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
vote(coll, id, guid, socket);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
db.collection(coll).find({id: id}, function(err, docs) {
|
||||||
|
if(docs.length === 0) {
|
||||||
|
var suggestedAdd = {
|
||||||
|
"added":Functions.get_time(),
|
||||||
|
"guids": [guid],
|
||||||
|
"id":id,
|
||||||
|
"now_playing": false,
|
||||||
|
"title":title,
|
||||||
|
"votes":1,
|
||||||
|
"duration":duration,
|
||||||
|
"start": start,
|
||||||
|
"end": end,
|
||||||
|
"type":"suggested"
|
||||||
|
};
|
||||||
|
var source = arr.source;
|
||||||
|
if(source == "soundcloud") {
|
||||||
|
suggestedAdd.thumbnail = arr.thumbnail;
|
||||||
|
suggestedAdd.source = source;
|
||||||
|
} else {
|
||||||
|
suggestedAdd.source = "youtube";
|
||||||
|
}
|
||||||
|
db.collection(coll).update({id: id}, {$set: suggestedAdd},
|
||||||
{upsert:true}, function(err, docs){
|
{upsert:true}, function(err, docs){
|
||||||
socket.emit("toast", "suggested");
|
socket.emit("toast", "suggested");
|
||||||
var toSend = {id: id, title: title, duration: duration, source: suggestedAdd.source};
|
var toSend = {id: id, title: title, duration: duration, source: suggestedAdd.source};
|
||||||
@@ -477,32 +482,32 @@ function add_function(arr, coll, guid, offline, socket) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
//});
|
//});
|
||||||
} else {
|
} else {
|
||||||
socket.emit("auth_required");
|
socket.emit("auth_required");
|
||||||
}
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
} else {
|
||||||
} else {
|
var result = {
|
||||||
var result = {
|
arr: {
|
||||||
arr: {
|
expected: "object",
|
||||||
expected: "object",
|
got: typeof(arr)
|
||||||
got: typeof(arr)
|
},
|
||||||
},
|
duration: {
|
||||||
duration: {
|
expected: "number or string that can be cast to int",
|
||||||
expected: "number or string that can be cast to int",
|
got: arr.hasOwnProperty("duration") ? typeof(arr.duration) : undefined,
|
||||||
got: arr.hasOwnProperty("duration") ? typeof(arr.duration) : undefined,
|
}
|
||||||
}
|
};
|
||||||
};
|
socket.emit('update_required', result);
|
||||||
socket.emit('update_required', result);
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
function voteUndecided(msg, coll, guid, offline, socket) {
|
function voteUndecided(msg, coll, guid, offline, socket) {
|
||||||
var socketid = socket.zoff_id;
|
var socketid = socket.zoff_id;
|
||||||
if(typeof(msg) === 'object' && msg !== undefined && msg !== null){
|
if(typeof(msg) === 'object' && msg !== undefined && msg !== null){
|
||||||
|
|
||||||
if(!msg.hasOwnProperty("channel") || !msg.hasOwnProperty("id") ||
|
if(!msg.hasOwnProperty("channel") || !msg.hasOwnProperty("id") ||
|
||||||
!msg.hasOwnProperty("type") || typeof(msg.channel) != "string" ||
|
!msg.hasOwnProperty("type") || typeof(msg.channel) != "string" ||
|
||||||
typeof(msg.id) != "string" || typeof(msg.type) != "string") {
|
typeof(msg.id) != "string" || typeof(msg.type) != "string") {
|
||||||
var result = {
|
var result = {
|
||||||
@@ -530,53 +535,53 @@ function voteUndecided(msg, coll, guid, offline, socket) {
|
|||||||
socket.emit('update_required', result);
|
socket.emit('update_required', result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
coll = msg.channel.toLowerCase();//.replace(/ /g,'');
|
coll = msg.channel.toLowerCase();//.replace(/ /g,'');
|
||||||
coll = Functions.removeEmojis(coll).toLowerCase();
|
coll = Functions.removeEmojis(coll).toLowerCase();
|
||||||
coll = filter.clean(coll);
|
coll = filter.clean(coll);
|
||||||
Functions.getSessionAdminUser(Functions.getSession(socket), coll, function(userpass, adminpass) {
|
Functions.getSessionAdminUser(Functions.getSession(socket), coll, function(userpass, adminpass) {
|
||||||
if(adminpass != "" || msg.adminpass == undefined) {
|
if(adminpass != "" || msg.adminpass == undefined) {
|
||||||
msg.adminpass = adminpass;
|
msg.adminpass = adminpass;
|
||||||
}
|
}
|
||||||
if(userpass != "" || msg.pass == undefined) {
|
if(userpass != "" || msg.pass == undefined) {
|
||||||
msg.pass = userpass;
|
msg.pass = userpass;
|
||||||
}
|
|
||||||
|
|
||||||
db.collection(coll + "_settings").find({id: "config"}, function(err, docs){
|
|
||||||
if(docs.length > 0 && (docs[0].userpass == undefined || docs[0].userpass == "" || (msg.hasOwnProperty('pass') && docs[0].userpass == crypto.createHash('sha256').update(Functions.decrypt_string(msg.pass)).digest("base64")))) {
|
|
||||||
|
|
||||||
Functions.check_inlist(coll, guid, socket, offline);
|
|
||||||
|
|
||||||
if(msg.type == "del") {
|
|
||||||
del(msg, socket, socketid);
|
|
||||||
} else {
|
|
||||||
var id = msg.id;
|
|
||||||
var hash = Functions.hash_pass(Functions.hash_pass(Functions.decrypt_string(msg.adminpass), true));
|
|
||||||
if(docs !== null && docs.length !== 0 && ((docs[0].vote === true && (hash == docs[0].adminpass || docs[0].adminpass === "")) ||
|
|
||||||
docs[0].vote === false)) {
|
|
||||||
vote(coll, id, guid, socket);
|
|
||||||
} else {
|
|
||||||
socket.emit("toast", "listhaspass");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
socket.emit("auth_required");
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
var result = {
|
|
||||||
msg: {
|
|
||||||
expected: "object",
|
|
||||||
got: typeof(msg)
|
|
||||||
}
|
|
||||||
};
|
|
||||||
socket.emit('update_required', result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function shuffle(msg, coll, guid, offline, socket) {
|
db.collection(coll + "_settings").find({id: "config"}, function(err, docs){
|
||||||
var socketid = socket.zoff_id;
|
if(docs.length > 0 && (docs[0].userpass == undefined || docs[0].userpass == "" || (msg.hasOwnProperty('pass') && docs[0].userpass == crypto.createHash('sha256').update(Functions.decrypt_string(msg.pass)).digest("base64")))) {
|
||||||
if(!msg.hasOwnProperty("channel") || typeof(msg.channel) != "string") {
|
|
||||||
|
Functions.check_inlist(coll, guid, socket, offline);
|
||||||
|
|
||||||
|
if(msg.type == "del") {
|
||||||
|
del(msg, socket, socketid);
|
||||||
|
} else {
|
||||||
|
var id = msg.id;
|
||||||
|
var hash = Functions.hash_pass(Functions.hash_pass(Functions.decrypt_string(msg.adminpass), true));
|
||||||
|
if(docs !== null && docs.length !== 0 && ((docs[0].vote === true && (hash == docs[0].adminpass || docs[0].adminpass === "")) ||
|
||||||
|
docs[0].vote === false)) {
|
||||||
|
vote(coll, id, guid, socket);
|
||||||
|
} else {
|
||||||
|
socket.emit("toast", "listhaspass");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
socket.emit("auth_required");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
var result = {
|
||||||
|
msg: {
|
||||||
|
expected: "object",
|
||||||
|
got: typeof(msg)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
socket.emit('update_required', result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function shuffle(msg, coll, guid, offline, socket) {
|
||||||
|
var socketid = socket.zoff_id;
|
||||||
|
if(!msg.hasOwnProperty("channel") || typeof(msg.channel) != "string") {
|
||||||
var result = {
|
var result = {
|
||||||
channel: {
|
channel: {
|
||||||
expected: "string",
|
expected: "string",
|
||||||
@@ -594,108 +599,108 @@ function shuffle(msg, coll, guid, offline, socket) {
|
|||||||
socket.emit('update_required', result);
|
socket.emit('update_required', result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
coll = msg.channel.toLowerCase();//.replace(/ /g,'');
|
coll = msg.channel.toLowerCase();//.replace(/ /g,'');
|
||||||
coll = Functions.removeEmojis(coll).toLowerCase();
|
coll = Functions.removeEmojis(coll).toLowerCase();
|
||||||
coll = filter.clean(coll);
|
coll = filter.clean(coll);
|
||||||
Functions.getSessionAdminUser(Functions.getSession(socket), coll, function(userpass, adminpass) {
|
Functions.getSessionAdminUser(Functions.getSession(socket), coll, function(userpass, adminpass) {
|
||||||
if(adminpass != "" || msg.adminpass == undefined) {
|
if(adminpass != "" || msg.adminpass == undefined) {
|
||||||
msg.adminpass = adminpass;
|
msg.adminpass = adminpass;
|
||||||
}
|
|
||||||
if(userpass != "" || msg.pass == undefined) {
|
|
||||||
msg.pass = userpass;
|
|
||||||
}
|
|
||||||
db.collection("timeout_api").find({
|
|
||||||
type: "shuffle",
|
|
||||||
guid: coll,
|
|
||||||
}, function(err, docs) {
|
|
||||||
if(docs.length > 0) {
|
|
||||||
var date = new Date(docs[0].createdAt);
|
|
||||||
date.setSeconds(date.getSeconds() + 5);
|
|
||||||
var now = new Date();
|
|
||||||
var retry_in = (date.getTime() - now.getTime()) / 1000;
|
|
||||||
if(retry_in > 0) {
|
|
||||||
socket.emit("toast", "wait_longer");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
var now_date = new Date();
|
if(userpass != "" || msg.pass == undefined) {
|
||||||
db.collection("timeout_api").update({type: "shuffle", guid: coll}, {
|
msg.pass = userpass;
|
||||||
$set: {
|
}
|
||||||
"createdAt": now_date,
|
db.collection("timeout_api").find({
|
||||||
type: "shuffle",
|
type: "shuffle",
|
||||||
guid: coll,
|
guid: coll,
|
||||||
},
|
}, function(err, docs) {
|
||||||
}, {upsert: true}, function(err, docs) {
|
if(docs.length > 0) {
|
||||||
Functions.check_inlist(coll, guid, socket, offline);
|
var date = new Date(docs[0].createdAt);
|
||||||
var hash;
|
date.setSeconds(date.getSeconds() + 5);
|
||||||
if(msg.adminpass === "") hash = msg.adminpass;
|
var now = new Date();
|
||||||
else hash = Functions.hash_pass(Functions.hash_pass(Functions.decrypt_string(msg.adminpass),true));
|
var retry_in = (date.getTime() - now.getTime()) / 1000;
|
||||||
db.collection(coll + "_settings").find(function(err, docs){
|
if(retry_in > 0) {
|
||||||
if(docs.length > 0 && (docs[0].userpass == undefined || docs[0].userpass == "" || (msg.hasOwnProperty('pass') && docs[0].userpass == crypto.createHash('sha256').update(Functions.decrypt_string(msg.pass)).digest("base64")))) {
|
socket.emit("toast", "wait_longer");
|
||||||
if(docs !== null && docs.length !== 0 && ((docs[0].adminpass == hash && docs[0].adminpass != "") || docs[0].shuffle === false))
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var now_date = new Date();
|
||||||
|
db.collection("timeout_api").update({type: "shuffle", guid: coll}, {
|
||||||
|
$set: {
|
||||||
|
"createdAt": now_date,
|
||||||
|
type: "shuffle",
|
||||||
|
guid: coll,
|
||||||
|
},
|
||||||
|
}, {upsert: true}, function(err, docs) {
|
||||||
|
Functions.check_inlist(coll, guid, socket, offline);
|
||||||
|
var hash;
|
||||||
|
if(msg.adminpass === "") hash = msg.adminpass;
|
||||||
|
else hash = Functions.hash_pass(Functions.hash_pass(Functions.decrypt_string(msg.adminpass),true));
|
||||||
|
db.collection(coll + "_settings").find(function(err, docs){
|
||||||
|
if(docs.length > 0 && (docs[0].userpass == undefined || docs[0].userpass == "" || (msg.hasOwnProperty('pass') && docs[0].userpass == crypto.createHash('sha256').update(Functions.decrypt_string(msg.pass)).digest("base64")))) {
|
||||||
|
if(docs !== null && docs.length !== 0 && ((docs[0].adminpass == hash && docs[0].adminpass != "") || docs[0].shuffle === false))
|
||||||
|
{
|
||||||
|
db.collection(coll).find({now_playing:false}).forEach(function(err, docs){
|
||||||
|
if(!docs){
|
||||||
|
List.send_list(coll, undefined, false, true, false, true);
|
||||||
|
socket.emit("toast", "shuffled");
|
||||||
|
|
||||||
|
return;
|
||||||
|
}else{
|
||||||
|
num = Math.floor(Math.random()*1000000);
|
||||||
|
db.collection(coll).update({id:docs.id}, {$set:{added:num}});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}else
|
||||||
|
socket.emit("toast", "wrongpass");
|
||||||
|
} else {
|
||||||
|
socket.emit("auth_required");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var complete = function(tot, curr){
|
||||||
|
if(tot == curr)
|
||||||
{
|
{
|
||||||
db.collection(coll).find({now_playing:false}).forEach(function(err, docs){
|
List.send_list(coll, undefined, false, true, false);
|
||||||
if(!docs){
|
List.getNextSong(coll, undefined);
|
||||||
List.send_list(coll, undefined, false, true, false, true);
|
}
|
||||||
socket.emit("toast", "shuffled");
|
};
|
||||||
|
|
||||||
return;
|
|
||||||
}else{
|
|
||||||
num = Math.floor(Math.random()*1000000);
|
|
||||||
db.collection(coll).update({id:docs.id}, {$set:{added:num}});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}else
|
|
||||||
socket.emit("toast", "wrongpass");
|
|
||||||
} else {
|
|
||||||
socket.emit("auth_required");
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
var complete = function(tot, curr){
|
|
||||||
if(tot == curr)
|
|
||||||
{
|
|
||||||
List.send_list(coll, undefined, false, true, false);
|
|
||||||
List.getNextSong(coll, undefined);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function del(params, socket, socketid) {
|
|
||||||
if(params.id){
|
|
||||||
var coll = Functions.removeEmojis(params.channel).toLowerCase();
|
|
||||||
//coll = coll.replace(/_/g, "").replace(/ /g,'');
|
|
||||||
|
|
||||||
coll = filter.clean(coll);
|
|
||||||
db.collection(coll + "_settings").find(function(err, docs){
|
|
||||||
if(docs !== null && docs.length !== 0 && docs[0].adminpass == Functions.hash_pass(Functions.hash_pass(Functions.decrypt_string(params.adminpass),true)))
|
|
||||||
{
|
|
||||||
db.collection(coll).find({id:params.id}, function(err, docs){
|
|
||||||
var dont_increment = false;
|
|
||||||
if(docs[0]){
|
|
||||||
if(docs[0].type == "suggested"){
|
|
||||||
dont_increment = true;
|
|
||||||
}
|
|
||||||
db.collection(coll).remove({id:params.id}, function(err, docs){
|
|
||||||
socket.emit("toast", "deletesong");
|
|
||||||
io.to(coll).emit("channel", {type:"deleted", value: params.id});
|
|
||||||
if(!dont_increment) db.collection("frontpage_lists").update({_id: coll, count: {$gt: 0}}, {$inc: {count: -1}, $set:{accessed: Functions.get_time()}}, {upsert: true}, function(err, docs){});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
function delete_all(msg, coll, guid, offline, socket) {
|
function del(params, socket, socketid) {
|
||||||
var socketid = socket.zoff_id;
|
if(params.id){
|
||||||
if(typeof(msg) == 'object' ) {
|
var coll = Functions.removeEmojis(params.channel).toLowerCase();
|
||||||
if(!msg.hasOwnProperty('channel') || typeof(msg.channel) != "string") {
|
//coll = coll.replace(/_/g, "").replace(/ /g,'');
|
||||||
|
|
||||||
|
coll = filter.clean(coll);
|
||||||
|
db.collection(coll + "_settings").find(function(err, docs){
|
||||||
|
if(docs !== null && docs.length !== 0 && docs[0].adminpass == Functions.hash_pass(Functions.hash_pass(Functions.decrypt_string(params.adminpass),true)))
|
||||||
|
{
|
||||||
|
db.collection(coll).find({id:params.id}, function(err, docs){
|
||||||
|
var dont_increment = false;
|
||||||
|
if(docs[0]){
|
||||||
|
if(docs[0].type == "suggested"){
|
||||||
|
dont_increment = true;
|
||||||
|
}
|
||||||
|
db.collection(coll).remove({id:params.id}, function(err, docs){
|
||||||
|
socket.emit("toast", "deletesong");
|
||||||
|
io.to(coll).emit("channel", {type:"deleted", value: params.id});
|
||||||
|
if(!dont_increment) db.collection("frontpage_lists").update({_id: coll, count: {$gt: 0}}, {$inc: {count: -1}, $set:{accessed: Functions.get_time()}}, {upsert: true}, function(err, docs){});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function delete_all(msg, coll, guid, offline, socket) {
|
||||||
|
var socketid = socket.zoff_id;
|
||||||
|
if(typeof(msg) == 'object' ) {
|
||||||
|
if(!msg.hasOwnProperty('channel') || typeof(msg.channel) != "string") {
|
||||||
var result = {
|
var result = {
|
||||||
channel: {
|
channel: {
|
||||||
expected: "string",
|
expected: "string",
|
||||||
@@ -742,43 +747,43 @@ function delete_all(msg, coll, guid, offline, socket) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
|
||||||
} else {
|
|
||||||
var result = {
|
|
||||||
msg: {
|
|
||||||
expected: "object",
|
|
||||||
got: typeof(msg)
|
|
||||||
},
|
|
||||||
};
|
|
||||||
socket.emit('update_required', result);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function vote(coll, id, guid, socket) {
|
|
||||||
//coll = coll.replace(/ /g,'');
|
|
||||||
db.collection(coll).find({id:id, now_playing: false, type:"video"}, function(err, docs){
|
|
||||||
if(docs !== null && docs.length > 0 && !Functions.contains(docs[0].guids, guid))
|
|
||||||
{
|
|
||||||
db.collection(coll).update({id:id}, {$inc:{votes:1}, $set:{added:Functions.get_time()}, $push :{guids: guid}}, function(err, docs)
|
|
||||||
{
|
|
||||||
socket.emit("toast", "voted");
|
|
||||||
io.to(coll).emit("channel", {type: "vote", value: id, time: Functions.get_time()});
|
|
||||||
|
|
||||||
List.getNextSong(coll, undefined);
|
|
||||||
});
|
});
|
||||||
}else
|
} else {
|
||||||
{
|
var result = {
|
||||||
socket.emit("toast", "alreadyvoted");
|
msg: {
|
||||||
|
expected: "object",
|
||||||
|
got: typeof(msg)
|
||||||
|
},
|
||||||
|
};
|
||||||
|
socket.emit('update_required', result);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
|
||||||
|
|
||||||
module.exports.addPlaylist = addPlaylist;
|
function vote(coll, id, guid, socket) {
|
||||||
module.exports.addFromOtherList = addFromOtherList;
|
//coll = coll.replace(/ /g,'');
|
||||||
module.exports.add_function = add_function;
|
db.collection(coll).find({id:id, now_playing: false, type:"video"}, function(err, docs){
|
||||||
module.exports.voteUndecided = voteUndecided;
|
if(docs !== null && docs.length > 0 && !Functions.contains(docs[0].guids, guid))
|
||||||
module.exports.shuffle = shuffle;
|
{
|
||||||
module.exports.del = del;
|
db.collection(coll).update({id:id}, {$inc:{votes:1}, $set:{added:Functions.get_time()}, $push :{guids: guid}}, function(err, docs)
|
||||||
module.exports.delete_all = delete_all;
|
{
|
||||||
module.exports.vote = vote;
|
socket.emit("toast", "voted");
|
||||||
|
io.to(coll).emit("channel", {type: "vote", value: id, time: Functions.get_time()});
|
||||||
|
|
||||||
|
List.getNextSong(coll, undefined);
|
||||||
|
});
|
||||||
|
}else
|
||||||
|
{
|
||||||
|
socket.emit("toast", "alreadyvoted");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports.addPlaylist = addPlaylist;
|
||||||
|
module.exports.addFromOtherList = addFromOtherList;
|
||||||
|
module.exports.add_function = add_function;
|
||||||
|
module.exports.voteUndecided = voteUndecided;
|
||||||
|
module.exports.shuffle = shuffle;
|
||||||
|
module.exports.del = del;
|
||||||
|
module.exports.delete_all = delete_all;
|
||||||
|
module.exports.vote = vote;
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ function getColor(id) {
|
|||||||
id: id
|
id: id
|
||||||
}),
|
}),
|
||||||
success: function(c) {
|
success: function(c) {
|
||||||
c = JSON.parse(c);
|
//c = JSON.parse(c);
|
||||||
if(typeof(c) == "object") {
|
if(typeof(c) == "object") {
|
||||||
Player.setBGimage({color:c, only:true});
|
Player.setBGimage({color:c, only:true});
|
||||||
}
|
}
|
||||||
@@ -201,7 +201,7 @@ function get_list_ajax() {
|
|||||||
if(response.results.length > 0) {
|
if(response.results.length > 0) {
|
||||||
if(response.status == 403) {
|
if(response.status == 403) {
|
||||||
start_auth();
|
start_auth();
|
||||||
}
|
} else if(response.status == 404) return;
|
||||||
if(client) {
|
if(client) {
|
||||||
Helper.removeElement("#channel-load");
|
Helper.removeElement("#channel-load");
|
||||||
}
|
}
|
||||||
@@ -209,14 +209,14 @@ function get_list_ajax() {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
error: function(response) {
|
error: function(response) {
|
||||||
response = JSON.parse(response);
|
//response = JSON.parse(response);
|
||||||
if(response.status == 403) {
|
if(response.status == 403) {
|
||||||
start_auth();
|
start_auth();
|
||||||
} else if(response.status == 429) {
|
} else if(response.status == 429) {
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
get_list_ajax();
|
get_list_ajax();
|
||||||
}, xmlhttp.getResponseHeader("Retry-After") * 1000)
|
}, xmlhttp.getResponseHeader("Retry-After") * 1000)
|
||||||
}
|
} else if(response.status == 404) return;
|
||||||
if(client) {
|
if(client) {
|
||||||
Helper.removeElement("#channel-load");
|
Helper.removeElement("#channel-load");
|
||||||
}
|
}
|
||||||
@@ -289,7 +289,7 @@ function get_np_ajax() {
|
|||||||
Player.getTitle(response.results[0].title, 1);
|
Player.getTitle(response.results[0].title, 1);
|
||||||
},
|
},
|
||||||
error: function(response, xmlhttp) {
|
error: function(response, xmlhttp) {
|
||||||
response = JSON.parse(response);
|
//response = JSON.parse(response);
|
||||||
if(response.status == 403) {
|
if(response.status == 403) {
|
||||||
start_auth();
|
start_auth();
|
||||||
} else if(response.status == 429) {
|
} else if(response.status == 429) {
|
||||||
@@ -320,7 +320,7 @@ function del_ajax(id) {
|
|||||||
get_list_ajax();
|
get_list_ajax();
|
||||||
},
|
},
|
||||||
error: function(response, xmlhttp) {
|
error: function(response, xmlhttp) {
|
||||||
response = JSON.parse(response);
|
//response = JSON.parse(response);
|
||||||
if(response.status == 403) {
|
if(response.status == 403) {
|
||||||
toast("listhaspass");
|
toast("listhaspass");
|
||||||
} else if(response.status == 429) {
|
} else if(response.status == 429) {
|
||||||
@@ -357,7 +357,7 @@ function add_ajax(id, title, duration, playlist, num, full_num, start, end, sour
|
|||||||
get_list_ajax();
|
get_list_ajax();
|
||||||
},
|
},
|
||||||
error: function(response, xmlhttp) {
|
error: function(response, xmlhttp) {
|
||||||
response = JSON.parse(response);
|
//response = JSON.parse(response);
|
||||||
if(response.status == 403) {
|
if(response.status == 403) {
|
||||||
toast("listhaspass");
|
toast("listhaspass");
|
||||||
} else if(response.status == 409) {
|
} else if(response.status == 409) {
|
||||||
@@ -390,7 +390,7 @@ function vote_ajax(id) {
|
|||||||
get_list_ajax();
|
get_list_ajax();
|
||||||
},
|
},
|
||||||
error: function(response, xmlhttp) {
|
error: function(response, xmlhttp) {
|
||||||
response = JSON.parse(response);
|
//response = JSON.parse(response);
|
||||||
if(response.status == 403) {
|
if(response.status == 403) {
|
||||||
toast("listhaspass");
|
toast("listhaspass");
|
||||||
} else if(response.status == 429) {
|
} else if(response.status == 429) {
|
||||||
@@ -1070,7 +1070,7 @@ function before_toast(){
|
|||||||
} catch(e) {
|
} catch(e) {
|
||||||
}
|
}
|
||||||
//}*/
|
//}*/
|
||||||
//M.Toast.dismissAll();
|
M.Toast.dismissAll();
|
||||||
//Materialize.Toast.removeAll();
|
//Materialize.Toast.removeAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1308,10 +1308,14 @@ window.addEventListener("resize", function(){
|
|||||||
} else if(window.innerWidth < 601) {
|
} else if(window.innerWidth < 601) {
|
||||||
if(!client && !embed) {
|
if(!client && !embed) {
|
||||||
var scPlaying = false;
|
var scPlaying = false;
|
||||||
|
var ytPlaying = false;
|
||||||
|
try {
|
||||||
|
ytPlaying = Player.player.getPlayerState() == YT.PlayerState.PLAYING || Player.player.getPlayerState() == YT.PlayerState.BUFFERING;
|
||||||
|
} catch(e) {}
|
||||||
try {
|
try {
|
||||||
scPlaying = Player.soundcloud_player.isPlaying();
|
scPlaying = Player.soundcloud_player.isPlaying();
|
||||||
} catch(e){}
|
} catch(e){}
|
||||||
resizePlaylistPlaying(Player.player.getPlayerState() == YT.PlayerState.PLAYING || scPlaying || Player.player.getPlayerState() == YT.PlayerState.BUFFERING);
|
resizePlaylistPlaying(ytPlaying || scPlaying);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -481,7 +481,8 @@ var Player = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
playNext: function(){
|
playNext: function(){
|
||||||
var next_song = full_playlist[0];
|
if(full_playlist.length == 0) return;
|
||||||
|
var next_song = full_playlist[0];
|
||||||
|
|
||||||
video_id = next_song.id;
|
video_id = next_song.id;
|
||||||
time = (new Date()).getTime();
|
time = (new Date()).getTime();
|
||||||
@@ -517,7 +518,7 @@ var Player = {
|
|||||||
var length = full_playlist.length - 2;
|
var length = full_playlist.length - 2;
|
||||||
if(length < 0) {
|
if(length < 0) {
|
||||||
length = 0;
|
length = 0;
|
||||||
}
|
} else if(length == 0) return;
|
||||||
var next_song = full_playlist[length];
|
var next_song = full_playlist[length];
|
||||||
video_id = next_song.id;
|
video_id = next_song.id;
|
||||||
time = (new Date()).getTime();
|
time = (new Date()).getTime();
|
||||||
|
|||||||
Reference in New Issue
Block a user