Fixed thumbnail issue

This commit is contained in:
Kasper Rynning-Tønnesen
2018-05-20 16:22:24 +02:00
parent 9db975e9e8
commit c25b45c314
4 changed files with 10 additions and 11 deletions

View File

@@ -17,7 +17,7 @@ function frontpage_lists(msg, socket) {
});
}
function update_frontpage(coll, id, title, thumbnail, callback) {
function update_frontpage(coll, id, title, thumbnail, source, callback) {
coll = coll.replace(/ /g,'');
db.collection("frontpage_lists").find({_id: coll}, function(e, doc) {
var updateObject = {
@@ -25,7 +25,7 @@ function update_frontpage(coll, id, title, thumbnail, callback) {
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)) {
if(doc.length > 0 && ((doc[0].thumbnail != "" && doc[0].thumbnail != undefined && doc[0].thumbnail.indexOf("https://i1.sndcdn.com") > -1) || (doc[0].thumbnail == "" || doc[0].thumbnail == undefined))) {
updateObject.thumbnail = thumbnail;
if(thumbnail == undefined) updateObject.thumbnail = "";
}

View File

@@ -381,7 +381,7 @@ function change_song_post(coll, next_song, callback, socket) {
List.send_play(coll, socket, true);
callback();
}
Frontpage.update_frontpage(coll, docs[0].id, docs[0].title, docs[0].thumbnail);
Frontpage.update_frontpage(coll, docs[0].id, docs[0].title, docs[0].thumbnail, docs[0].source);
});
});
});
@@ -439,7 +439,7 @@ function send_list(coll, socket, send, list_send, configs, shuffled)
skips:[]
}
}, function(err, returnDocs){
Frontpage.update_frontpage(coll, now_playing_doc[0].id, now_playing_doc[0].title, now_playing_doc[0].thumbnail);
Frontpage.update_frontpage(coll, now_playing_doc[0].id, now_playing_doc[0].title, now_playing_doc[0].thumbnail, now_playing_doc[0].source);
List.send_list(coll, socket, send, list_send, configs, shuffled);
});
});

View File

@@ -55,8 +55,8 @@ function addFromOtherList(arr, guid, offline, socket) {
project_object.now_playing = { "$literal": false };
to_set_np = false;
}
db.collection(new_channel + "_settings").find({id: "config"}, function(e, new_conf) {
if(new_conf.length > 0 && (new_conf[0].userpass == "" || !new_conf[0].userpass || new_conf[0].userpass == crypto.createHash('sha256').update(Functions.decrypt_string(otheruser)).digest("base64"))) {
db.collection(new_channel + "_settings").find({id: "config"}, function(e, this_conf) {
if(this_conf.length > 0 && (this_conf[0].userpass == "" || !this_conf[0].userpass || this_conf[0].userpass == crypto.createHash('sha256').update(Functions.decrypt_string(otheruser)).digest("base64"))) {
db.collection(channel + "_settings").find({id: "config"}, function(e, this_conf) {
var hash = Functions.hash_pass(Functions.hash_pass(Functions.decrypt_string(arr.adminpass), true));
if((this_conf[0].userpass == "" || !this_conf[0].userpass || this_conf[0].userpass == crypto.createHash('sha256').update(Functions.decrypt_string(arr.userpass)).digest("base64"))) {
@@ -89,7 +89,7 @@ function addFromOtherList(arr, guid, offline, socket) {
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) {
if(doc.length > 0 && ((doc[0].thumbnail != "" && doc[0].thumbnail != undefined && doc[0].thumbnail.indexOf("https://i1.sndcdn.com") > -1) || (doc[0].thumbnail == "" || doc[0].thumbnail == undefined))) {
to_change.thumbnail = np_docs[0].thumbnail;
}
@@ -225,7 +225,7 @@ function addPlaylist(arr, guid, offline, socket) {
to_change.id = np_docs[0].id;
to_change.title = np_docs[0].title;
db.collection("frontpage_lists").find({_id: channel}, function(e, doc) {
if(doc.length > 0 && 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 == "" || doc[0].thumbnail == undefined))) {
to_change.thumbnail = np_docs[0].thumbnail;
}
@@ -398,7 +398,7 @@ function add_function(arr, coll, guid, offline, socket) {
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);
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});

View File

@@ -712,7 +712,6 @@ router.route('/api/list/:channel_name/:video_id').post(function(req,res) {
var type = fetch_only ? "fetch_song" : "add";
validateLogin(adminpass, userpass, channel_name, type, res, function(exists, conf, authenticated) {
db.collection(channel_name).find({id: video_id}, function(err, result) {
console.log(result);
if(result.length == 0 || result[0].type == "suggested") {
var song_type = authenticated ? "video" : "suggested";
if(fetch_only && result.length == 0) {
@@ -764,7 +763,7 @@ router.route('/api/list/:channel_name/:video_id').post(function(req,res) {
});
} else if(set_np) {
var thumbnail = req.body.thumbnail != undefined ? req.body.thumbnail : undefined;
Frontpage.update_frontpage(channel_name, video_id, title, thumbnail, function() {
Frontpage.update_frontpage(channel_name, video_id, title, thumbnail, source, function() {
io.to(channel_name).emit("np", {np: [new_song], conf: [conf]});
postEnd(channel_name, configs, new_song, guid, res, authenticated, authorized);
});