Merge pull request #523 from zoff-music/feat/added-by-suggest

Added by on suggested songs
This commit is contained in:
Kasper Rynning-Tønnesen
2019-08-07 16:13:18 +02:00
committed by GitHub
4 changed files with 172 additions and 152 deletions

View File

@@ -30,6 +30,7 @@ var project_object = {
duration: 1, duration: 1,
end: 1, end: 1,
type: 1, type: 1,
added_by: { $ifNull: ["$added_by", "Anonymous"] },
source: { $ifNull: ["$source", "youtube"] }, source: { $ifNull: ["$source", "youtube"] },
thumbnail: { thumbnail: {
$ifNull: [ $ifNull: [

View File

@@ -71,6 +71,16 @@ function getAndSendLogs(channel, all, socket, pass, query) {
}); });
} }
function getUserNameByGuid(guid, callback) {
db.collection("user_names").find({ guid: guid }, function(err, usernames) {
if (usernames.length == 1) {
callback(usernames[0].name);
return;
}
callback("Anonymous");
});
}
function chat(msg, guid, offline, socket) { function chat(msg, guid, offline, socket) {
if ( if (
typeof msg !== "object" || typeof msg !== "object" ||
@@ -909,6 +919,7 @@ function get_name_generate(guid, announce_payload, first, channel) {
}); });
} }
module.exports.getUserNameByGuid = getUserNameByGuid;
module.exports.get_history = get_history; module.exports.get_history = get_history;
module.exports.chat = chat; module.exports.chat = chat;
module.exports.all_chat = all_chat; module.exports.all_chat = all_chat;

View File

@@ -2,6 +2,7 @@ var Functions = require(pathThumbnails + "/handlers/functions.js");
var List = require(pathThumbnails + "/handlers/list.js"); var List = require(pathThumbnails + "/handlers/list.js");
var Frontpage = require(pathThumbnails + "/handlers/frontpage.js"); var Frontpage = require(pathThumbnails + "/handlers/frontpage.js");
var Search = require(pathThumbnails + "/handlers/search.js"); var Search = require(pathThumbnails + "/handlers/search.js");
var Chat = require(pathThumbnails + "/handlers/chat.js");
var crypto = require("crypto"); var crypto = require("crypto");
var Filter = require("bad-words"); var Filter = require("bad-words");
var filter = new Filter({ placeHolder: "x" }); var filter = new Filter({ placeHolder: "x" });
@@ -819,6 +820,7 @@ function add_function(arr, coll, guid, offline, socket) {
var source = arr.source; var source = arr.source;
var tags = arr.tags; var tags = arr.tags;
conf = docs; conf = docs;
Chat.getUserNameByGuid(guid, function(username) {
if ( if (
docs !== null && docs !== null &&
docs.length !== 0 && docs.length !== 0 &&
@@ -854,7 +856,8 @@ function add_function(arr, coll, guid, offline, socket) {
start: parseInt(start), start: parseInt(start),
end: parseInt(end), end: parseInt(end),
type: "video", type: "video",
source: source source: source,
added_by: username
}; };
if (source == "soundcloud") { if (source == "soundcloud") {
if ( if (
@@ -942,7 +945,8 @@ function add_function(arr, coll, guid, offline, socket) {
start: start, start: start,
end: end, end: end,
type: "suggested", type: "suggested",
tags: tags tags: tags,
added_by: username
}; };
var source = arr.source; var source = arr.source;
if (source == "soundcloud") { if (source == "soundcloud") {
@@ -962,6 +966,10 @@ function add_function(arr, coll, guid, offline, socket) {
if (source == "soundcloud") if (source == "soundcloud")
toSend.thumbnail = arr.thumbnail; toSend.thumbnail = arr.thumbnail;
io.to(coll).emit("suggested", toSend); io.to(coll).emit("suggested", toSend);
if (source != "soundcloud")
Search.get_correct_info(suggestedAdd, coll, false);
else if (source == "soundcloud")
Search.get_genres_soundcloud(suggestedAdd, coll);
} }
); );
} else if (docs[0].now_playing === true) { } else if (docs[0].now_playing === true) {
@@ -972,6 +980,7 @@ function add_function(arr, coll, guid, offline, socket) {
} }
}); });
} }
});
} else { } else {
if ( if (
(arr.hasOwnProperty("offsiteAdd") && !arr.offsiteAdd) || (arr.hasOwnProperty("offsiteAdd") && !arr.offsiteAdd) ||

View File

@@ -36,10 +36,6 @@ var Suggestions = {
var video_title = params.title; var video_title = params.title;
var date = new Date(params.added * 1000); var date = new Date(params.added * 1000);
var addedTime = var addedTime =
Helper.pad(date.getHours()) +
":" +
Helper.pad(date.getMinutes()) +
" - " +
Helper.pad(date.getDate()) + Helper.pad(date.getDate()) +
"." + "." +
Helper.pad(date.getMonth()) + Helper.pad(date.getMonth()) +
@@ -53,6 +49,9 @@ var Suggestions = {
votes: addedTime, votes: addedTime,
extra: "Added" extra: "Added"
}; };
if (params.added_by != undefined) {
toSend.extra += " by " + params.added_by;
}
if (params.source) toSend.source = params.source; if (params.source) toSend.source = params.source;
else { else {
toSend.source = "youtube"; toSend.source = "youtube";