This commit is contained in:
Kasper Rynning-Tønnesen
2018-07-10 16:21:16 +02:00
parent 061b3832ae
commit d3e6af4643
4 changed files with 406 additions and 396 deletions

View File

@@ -93,17 +93,19 @@ 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).count({type: {$ne: "suggested"}}, function(err, count) {
db.collection(channel + "_settings").update({id: "config"}, {$set: {startTime: Functions.get_time()}}, function(e,d) { db.collection(channel + "_settings").update({id: "config"}, {$set: {startTime: Functions.get_time()}}, function(e,d) {
if(to_set_np) { if(to_set_np) {
var to_change = { var to_change = {
_id: channel, _id: channel,
count: res.nInserted != undefined ? res.nInserted : res.insertedCount, count: count,
frontpage: true, frontpage: true,
accessed: Functions.get_time(), accessed: Functions.get_time(),
} }
db.collection(channel).find({now_playing: true}, function(e, np_docs) { db.collection(channel).find({now_playing: true}, function(e, np_docs) {
to_change.id = np_docs[0].id; to_change.id = np_docs[0].id;
to_change.title = np_docs[0].title; to_change.title = np_docs[0].title;
db.collection("frontpage_lists").find({_id: coll}, function(e, doc) { db.collection("frontpage_lists").find({_id: coll}, function(e, doc) {
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))) { 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; to_change.thumbnail = np_docs[0].thumbnail;
@@ -118,7 +120,7 @@ function addFromOtherList(arr, guid, offline, socket) {
}); });
}); });
} else { } else {
db.collection("frontpage_lists").update({_id: channel}, {$inc: {count: res.nInserted != undefined ? res.nInserted : res.insertedCount}}, function(e, d) { db.collection("frontpage_lists").update({_id: channel}, {$set: {count: count}}, 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");
@@ -129,6 +131,7 @@ function addFromOtherList(arr, guid, offline, socket) {
}); });
}); });
}); });
});
} else { } else {
socket.emit("toast", "listhaspass"); socket.emit("toast", "listhaspass");
return; return;
@@ -236,11 +239,12 @@ 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).count({type: {$ne: "suggested"}}, function(err, count) {
db.collection(channel + "_settings").update({id: "config"}, {$set: {startTime: Functions.get_time()}}, function(e,d) { db.collection(channel + "_settings").update({id: "config"}, {$set: {startTime: Functions.get_time()}}, function(e,d) {
if(to_set_np) { if(to_set_np) {
var to_change = { var to_change = {
_id: channel, _id: channel,
count: results.nInserted, count: count,
frontpage: true, frontpage: true,
accessed: Functions.get_time(), accessed: Functions.get_time(),
} }
@@ -261,7 +265,7 @@ function addPlaylist(arr, guid, offline, socket) {
}); });
}); });
} else { } else {
db.collection("frontpage_lists").update({_id: channel}, {$inc: {count: results.nInserted != undefined ? results.nInserted : results.insertedCount}}, function(e, d) { db.collection("frontpage_lists").update({_id: channel}, {$set: {count: count}}, 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");
@@ -271,6 +275,7 @@ function addPlaylist(arr, guid, offline, socket) {
}); });
}); });
}); });
});
} else { } else {
socket.emit("toast", "listhaspass"); socket.emit("toast", "listhaspass");
return; return;

View File

@@ -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();
} }

View File

@@ -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;
} }
} }

View File

@@ -481,6 +481,7 @@ var Player = {
}, },
playNext: function(){ playNext: function(){
if(full_playlist.length == 0) return;
var next_song = full_playlist[0]; var next_song = full_playlist[0];
video_id = next_song.id; video_id = next_song.id;
@@ -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();