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) {
|
||||
coll = coll.replace(/ /g,'');
|
||||
db.collection("frontpage_lists").update({_id: coll}, {$set: {
|
||||
id: id,
|
||||
title: title,
|
||||
thumbnail: thumbnail,
|
||||
accessed: Functions.get_time()}
|
||||
},{upsert: true}, function(err, returnDocs){
|
||||
if(typeof(callback) == "function") callback();
|
||||
db.collection("frontpage_lists").find({_id: coll}, function(e, doc) {
|
||||
var updateObject = {
|
||||
id: id,
|
||||
title: title,
|
||||
accessed: Functions.get_time()
|
||||
};
|
||||
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) {
|
||||
to_change.id = np_docs[0].id;
|
||||
to_change.title = np_docs[0].title;
|
||||
to_change.thumbnail = np_docs[0].thumbnail;
|
||||
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();
|
||||
db.collection("frontpage_lists").find({_id: coll}, function(e, doc) {
|
||||
if(doc.length > 0 && 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) {
|
||||
List.send_list(channel, undefined, false, true, false);
|
||||
List.send_play(channel, undefined);
|
||||
socket.emit("toast", "addedplaylist");
|
||||
_db.close();
|
||||
});
|
||||
});
|
||||
});
|
||||
} else {
|
||||
@@ -219,12 +224,17 @@ function addPlaylist(arr, guid, offline, socket) {
|
||||
db.collection(channel).find({now_playing: true}, function(e, np_docs) {
|
||||
to_change.id = np_docs[0].id;
|
||||
to_change.title = np_docs[0].title;
|
||||
to_change.thumbnail = np_docs[0].thumbnail;
|
||||
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();
|
||||
db.collection("frontpage_lists").find({_id: coll}, function(e, doc) {
|
||||
if(doc.length > 0 && 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) {
|
||||
List.send_list(channel, undefined, false, true, false);
|
||||
List.send_play(channel, undefined);
|
||||
socket.emit("toast", "addedplaylist");
|
||||
_db.close();
|
||||
});
|
||||
});
|
||||
});
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user