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,14 +19,22 @@ 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: {
|
||||
db.collection("frontpage_lists").find({_id: coll}, function(e, doc) {
|
||||
var updateObject = {
|
||||
id: id,
|
||||
title: title,
|
||||
thumbnail: thumbnail,
|
||||
accessed: Functions.get_time()}
|
||||
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();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
module.exports.frontpage_lists = frontpage_lists;
|
||||
|
||||
@@ -88,7 +88,11 @@ 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;
|
||||
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);
|
||||
@@ -96,6 +100,7 @@ function addFromOtherList(arr, guid, offline, socket) {
|
||||
_db.close();
|
||||
});
|
||||
});
|
||||
});
|
||||
} else {
|
||||
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);
|
||||
@@ -219,7 +224,11 @@ 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;
|
||||
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);
|
||||
@@ -227,6 +236,7 @@ function addPlaylist(arr, guid, offline, socket) {
|
||||
_db.close();
|
||||
});
|
||||
});
|
||||
});
|
||||
} else {
|
||||
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);
|
||||
|
||||
@@ -78,20 +78,16 @@ var Frontpage = {
|
||||
var viewers = lists[x].viewers;
|
||||
var description = lists[x].description;
|
||||
var img;
|
||||
if(id.indexOf("soundcloud.com") > -1) {
|
||||
img = "background-image:url('" + lists[x].thumbnail + "');";
|
||||
} else {
|
||||
img = "background-image:url('https://img.youtube.com/vi/"+id+"/hqdefault.jpg');";
|
||||
if(lists[x].thumbnail) {
|
||||
if(lists[x].thumbnail && lists[x].thumbnail != "") {
|
||||
img = "background-image:url('" + lists[x].thumbnail + "');";
|
||||
}
|
||||
}
|
||||
|
||||
var song_count = lists[x].count;
|
||||
var card = document.createElement("div");
|
||||
card.innerHTML += pre_card;
|
||||
//card.innerHTML = card.children[0];
|
||||
if(song_count > 4) {
|
||||
if(song_count > 3) {
|
||||
if(lists[x].pinned == 1) {
|
||||
card.querySelector(".pin").setAttribute("style", "display:block;");
|
||||
//card.find(".card").attr("title", "Featured list");
|
||||
|
||||
@@ -194,7 +194,6 @@ var Search = {
|
||||
SC.get('/tracks', {
|
||||
q: keyword
|
||||
}).then(function(tracks) {
|
||||
|
||||
var pre_result = document.createElement("div");
|
||||
pre_result.innerHTML = result_html.outerHTML;
|
||||
|
||||
@@ -203,7 +202,7 @@ var Search = {
|
||||
var output = "";
|
||||
for(var i = 0; i < tracks.length; i++) {
|
||||
var song = tracks[i];
|
||||
|
||||
if(!song.streamable) continue;
|
||||
var duration=Math.floor(song.duration / 1000);
|
||||
//var secs=Search.durationToSeconds(duration);
|
||||
var secs = duration;
|
||||
@@ -391,13 +390,13 @@ var Search = {
|
||||
}
|
||||
},
|
||||
error: function(e) {
|
||||
console.log(e);
|
||||
console.error(e);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}, error: function(e) {
|
||||
console.log(e);
|
||||
console.error(e);
|
||||
}
|
||||
});
|
||||
},
|
||||
@@ -623,7 +622,7 @@ addVideos: function(ids){
|
||||
}
|
||||
},
|
||||
error: function(e) {
|
||||
console.log(e);
|
||||
console.error(e);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user