mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
Better handling for frontpage-lists thumbnails
This commit is contained in:
@@ -19,13 +19,21 @@ function frontpage_lists(msg, socket) {
|
|||||||
|
|
||||||
function update_frontpage(coll, id, title, thumbnail, callback) {
|
function update_frontpage(coll, id, title, thumbnail, callback) {
|
||||||
coll = coll.replace(/ /g,'');
|
coll = coll.replace(/ /g,'');
|
||||||
db.collection("frontpage_lists").update({_id: coll}, {$set: {
|
db.collection("frontpage_lists").find({_id: coll}, function(e, doc) {
|
||||||
id: id,
|
var updateObject = {
|
||||||
title: title,
|
id: id,
|
||||||
thumbnail: thumbnail,
|
title: title,
|
||||||
accessed: Functions.get_time()}
|
accessed: Functions.get_time()
|
||||||
},{upsert: true}, function(err, returnDocs){
|
};
|
||||||
if(typeof(callback) == "function") callback();
|
if(doc.length > 0 && (doc[0].thumbnail == "" || doc[0].thumbnail == undefined || doc[0].thumbnail.indexOf("ttps://i1.sndcdn.com") > -1)) {
|
||||||
|
updateObject.thumbnail = thumbnail;
|
||||||
|
if(thumbnail == undefined) updateObject.thumbnail = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
db.collection("frontpage_lists").update({_id: coll}, {$set: updateObject
|
||||||
|
},{upsert: true}, function(err, returnDocs){
|
||||||
|
if(typeof(callback) == "function") callback();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -88,12 +88,17 @@ function addFromOtherList(arr, guid, offline, socket) {
|
|||||||
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;
|
||||||
to_change.thumbnail = np_docs[0].thumbnail;
|
db.collection("frontpage_lists").find({_id: coll}, function(e, doc) {
|
||||||
db.collection("frontpage_lists").update({_id: channel}, {$set: to_change}, function(e, d) {
|
if(doc.length > 0 && doc[0].thumbnail != "" && doc[0].thumbnail != undefined) {
|
||||||
List.send_list(channel, undefined, false, true, false);
|
to_change.thumbnail = np_docs[0].thumbnail;
|
||||||
List.send_play(channel, undefined);
|
}
|
||||||
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 {
|
||||||
@@ -219,12 +224,17 @@ function addPlaylist(arr, guid, offline, socket) {
|
|||||||
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;
|
||||||
to_change.thumbnail = np_docs[0].thumbnail;
|
db.collection("frontpage_lists").find({_id: coll}, function(e, doc) {
|
||||||
db.collection("frontpage_lists").update({_id: channel}, {$set: to_change}, function(e, d) {
|
if(doc.length > 0 && doc[0].thumbnail != "" && doc[0].thumbnail != undefined) {
|
||||||
List.send_list(channel, undefined, false, true, false);
|
to_change.thumbnail = np_docs[0].thumbnail;
|
||||||
List.send_play(channel, undefined);
|
}
|
||||||
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 {
|
||||||
|
|||||||
@@ -78,20 +78,16 @@ var Frontpage = {
|
|||||||
var viewers = lists[x].viewers;
|
var viewers = lists[x].viewers;
|
||||||
var description = lists[x].description;
|
var description = lists[x].description;
|
||||||
var img;
|
var img;
|
||||||
if(id.indexOf("soundcloud.com") > -1) {
|
img = "background-image:url('https://img.youtube.com/vi/"+id+"/hqdefault.jpg');";
|
||||||
|
if(lists[x].thumbnail && lists[x].thumbnail != "") {
|
||||||
img = "background-image:url('" + lists[x].thumbnail + "');";
|
img = "background-image:url('" + lists[x].thumbnail + "');";
|
||||||
} else {
|
|
||||||
img = "background-image:url('https://img.youtube.com/vi/"+id+"/hqdefault.jpg');";
|
|
||||||
if(lists[x].thumbnail) {
|
|
||||||
img = "background-image:url('" + lists[x].thumbnail + "');";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var song_count = lists[x].count;
|
var song_count = lists[x].count;
|
||||||
var card = document.createElement("div");
|
var card = document.createElement("div");
|
||||||
card.innerHTML += pre_card;
|
card.innerHTML += pre_card;
|
||||||
//card.innerHTML = card.children[0];
|
//card.innerHTML = card.children[0];
|
||||||
if(song_count > 4) {
|
if(song_count > 3) {
|
||||||
if(lists[x].pinned == 1) {
|
if(lists[x].pinned == 1) {
|
||||||
card.querySelector(".pin").setAttribute("style", "display:block;");
|
card.querySelector(".pin").setAttribute("style", "display:block;");
|
||||||
//card.find(".card").attr("title", "Featured list");
|
//card.find(".card").attr("title", "Featured list");
|
||||||
|
|||||||
@@ -194,7 +194,6 @@ var Search = {
|
|||||||
SC.get('/tracks', {
|
SC.get('/tracks', {
|
||||||
q: keyword
|
q: keyword
|
||||||
}).then(function(tracks) {
|
}).then(function(tracks) {
|
||||||
|
|
||||||
var pre_result = document.createElement("div");
|
var pre_result = document.createElement("div");
|
||||||
pre_result.innerHTML = result_html.outerHTML;
|
pre_result.innerHTML = result_html.outerHTML;
|
||||||
|
|
||||||
@@ -203,7 +202,7 @@ var Search = {
|
|||||||
var output = "";
|
var output = "";
|
||||||
for(var i = 0; i < tracks.length; i++) {
|
for(var i = 0; i < tracks.length; i++) {
|
||||||
var song = tracks[i];
|
var song = tracks[i];
|
||||||
|
if(!song.streamable) continue;
|
||||||
var duration=Math.floor(song.duration / 1000);
|
var duration=Math.floor(song.duration / 1000);
|
||||||
//var secs=Search.durationToSeconds(duration);
|
//var secs=Search.durationToSeconds(duration);
|
||||||
var secs = duration;
|
var secs = duration;
|
||||||
@@ -391,13 +390,13 @@ var Search = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
error: function(e) {
|
error: function(e) {
|
||||||
console.log(e);
|
console.error(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
}, error: function(e) {
|
}, error: function(e) {
|
||||||
console.log(e);
|
console.error(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -623,7 +622,7 @@ addVideos: function(ids){
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
error: function(e) {
|
error: function(e) {
|
||||||
console.log(e);
|
console.error(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user