mirror of
https://github.com/KevinMidboe/zoff.git
synced 2026-01-09 02:55:35 +00:00
7
package-lock.json
generated
7
package-lock.json
generated
@@ -2204,7 +2204,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"combined-stream": {
|
"combined-stream": {
|
||||||
"version": "1.0.6",
|
"version": "1.0.6",
|
||||||
"resolved": "http://registry.npmjs.org/combined-stream/-/combined-stream-1.0.6.tgz",
|
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.6.tgz",
|
||||||
"integrity": "sha1-cj599ugBrFYTETp+RFqbactjKBg=",
|
"integrity": "sha1-cj599ugBrFYTETp+RFqbactjKBg=",
|
||||||
"requires": {
|
"requires": {
|
||||||
"delayed-stream": "~1.0.0"
|
"delayed-stream": "~1.0.0"
|
||||||
@@ -3863,6 +3863,11 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"mongojs-paginate": {
|
||||||
|
"version": "1.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/mongojs-paginate/-/mongojs-paginate-1.2.0.tgz",
|
||||||
|
"integrity": "sha1-Z3YjmDlByAOPyBz88lw+425iO4s="
|
||||||
|
},
|
||||||
"mongoose": {
|
"mongoose": {
|
||||||
"version": "5.0.16",
|
"version": "5.0.16",
|
||||||
"resolved": "https://registry.npmjs.org/mongoose/-/mongoose-5.0.16.tgz",
|
"resolved": "https://registry.npmjs.org/mongoose/-/mongoose-5.0.16.tgz",
|
||||||
|
|||||||
@@ -46,6 +46,7 @@
|
|||||||
"jimp": "^0.2.28",
|
"jimp": "^0.2.28",
|
||||||
"mongodb": "^2.2.35",
|
"mongodb": "^2.2.35",
|
||||||
"mongojs": "^2.5.0",
|
"mongojs": "^2.5.0",
|
||||||
|
"mongojs-paginate": "^1.2.0",
|
||||||
"mongoose": "^5.0.16",
|
"mongoose": "^5.0.16",
|
||||||
"mpromise": "^0.5.5",
|
"mpromise": "^0.5.5",
|
||||||
"nodemailer": "^4.6.4",
|
"nodemailer": "^4.6.4",
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ app.use(bodyParser.urlencoded({ // to support URL-encoded bodies
|
|||||||
extended: true
|
extended: true
|
||||||
}));
|
}));
|
||||||
app.use(cookieParser());
|
app.use(cookieParser());
|
||||||
app.set('json spaces', 2);
|
//app.set('json spaces', 2);
|
||||||
|
|
||||||
io = require('socket.io')({
|
io = require('socket.io')({
|
||||||
pingTimeout: 25000,
|
pingTimeout: 25000,
|
||||||
|
|||||||
74
server/apps/genre_generator.js
Normal file
74
server/apps/genre_generator.js
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
var path = require('path');
|
||||||
|
var publicPath = path.join(__dirname, 'public');
|
||||||
|
var pathThumbnail = __dirname;
|
||||||
|
pathThumbnails = __dirname + "/../";
|
||||||
|
var time_regex = /P((([0-9]*\.?[0-9]*)Y)?(([0-9]*\.?[0-9]*)M)?(([0-9]*\.?[0-9]*)W)?(([0-9]*\.?[0-9]*)D)?)?(T(([0-9]*\.?[0-9]*)H)?(([0-9]*\.?[0-9]*)M)?(([0-9]*\.?[0-9]*)S)?)?/;
|
||||||
|
try {
|
||||||
|
var keys = require(path.join(__dirname, '../config/api_key.js'));
|
||||||
|
var key = keys.youtube;
|
||||||
|
var soundcloudKey = keys.soundcloud;
|
||||||
|
} catch(e) {
|
||||||
|
console.log("Error - missing file");
|
||||||
|
console.log("Seems you forgot to create the file api_key.js in /server/config/. Have a look at api_key.example.js.");
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
var Search = require(pathThumbnail + '/../handlers/search.js');
|
||||||
|
var request = require('request');
|
||||||
|
var db = require(pathThumbnail + '/../handlers/db.js');
|
||||||
|
var currentList = 0;
|
||||||
|
var listNames = [];
|
||||||
|
db.getCollectionNames(function(e, d) {
|
||||||
|
for(var i = 0; i < d.length; i++) {
|
||||||
|
if(d[i].indexOf("_") < 0) {
|
||||||
|
if(d[i].length > 0) {
|
||||||
|
if(d[i].substring(0, 1) == "." || d[i].substring(d[i].length - 1) == ".") continue;
|
||||||
|
}
|
||||||
|
listNames.push(d[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.log("Number of lists is " + listNames.length);
|
||||||
|
/*for(var i = 0; i < listNames.length; i++) {
|
||||||
|
getListItems(d[i]);
|
||||||
|
if(i > 1000) return;
|
||||||
|
}*/
|
||||||
|
recursivifyListLooping(listNames, 0);
|
||||||
|
});
|
||||||
|
|
||||||
|
function filterFunction(el) {
|
||||||
|
return el != null &&
|
||||||
|
el != "" &&
|
||||||
|
el != undefined &&
|
||||||
|
el.trim() != ''
|
||||||
|
}
|
||||||
|
|
||||||
|
function recursivifyListLooping(listNames, i) {
|
||||||
|
if(i > listNames.length) {
|
||||||
|
console.log("Done");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
console.log("List " + i + " of " + listNames.length);
|
||||||
|
getListItems(listNames, 0, function() {
|
||||||
|
console.log("done");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function getListItems(arr, i, callback) {
|
||||||
|
console.log("List " + i + " of " + listNames.length + " - " + arr[i]);
|
||||||
|
if(i >= arr.length) {
|
||||||
|
if(typeof(callback) == "function") callback();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
db.collection(arr[i]).find(function(e, d) {
|
||||||
|
if(d.length > 0) {
|
||||||
|
Search.get_genres_list_recursive(d, arr[i], function(){
|
||||||
|
getListItems(arr, i + 1, callback);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
getListItems(arr, i + 1, callback);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch(e) {
|
||||||
|
getListItems(arr, i + 1, callback);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -35,7 +35,8 @@ var project_object = {
|
|||||||
$ifNull: [ "$thumbnail", {
|
$ifNull: [ "$thumbnail", {
|
||||||
$concat : [ "https://img.youtube.com/vi/", "$id", "/mqdefault.jpg"]
|
$concat : [ "https://img.youtube.com/vi/", "$id", "/mqdefault.jpg"]
|
||||||
} ]
|
} ]
|
||||||
}
|
},
|
||||||
|
"tags": { $ifNull: [ "$tags", [] ] },
|
||||||
};
|
};
|
||||||
|
|
||||||
var toShowChannel = {
|
var toShowChannel = {
|
||||||
@@ -48,6 +49,7 @@ var toShowChannel = {
|
|||||||
duration: 1,
|
duration: 1,
|
||||||
type: 1,
|
type: 1,
|
||||||
_id: 0,
|
_id: 0,
|
||||||
|
tags: 1,
|
||||||
now_playing: 1,
|
now_playing: 1,
|
||||||
type: 1,
|
type: 1,
|
||||||
source: 1,
|
source: 1,
|
||||||
|
|||||||
@@ -70,7 +70,8 @@ function addFromOtherList(arr, guid, offline, socket) {
|
|||||||
"end": 1,
|
"end": 1,
|
||||||
"type": 1,
|
"type": 1,
|
||||||
"source": 1,
|
"source": 1,
|
||||||
"thumbnail": 1
|
"thumbnail": 1,
|
||||||
|
"tags": 1
|
||||||
};
|
};
|
||||||
var to_set_np = true;
|
var to_set_np = true;
|
||||||
if(np.length > 0) {
|
if(np.length > 0) {
|
||||||
@@ -241,6 +242,7 @@ function addPlaylist(arr, guid, offline, socket) {
|
|||||||
this_element.start = parseInt(this_element.start);
|
this_element.start = parseInt(this_element.start);
|
||||||
this_element.end = parseInt(this_element.end);
|
this_element.end = parseInt(this_element.end);
|
||||||
this_element.type = "video";
|
this_element.type = "video";
|
||||||
|
if(this_element.tags == undefined) this_element.tags = [];
|
||||||
this_element.duration = parseInt(this_element.duration);
|
this_element.duration = parseInt(this_element.duration);
|
||||||
if(this_element.start > this_element.end) {
|
if(this_element.start > this_element.end) {
|
||||||
this_element.start = 0;
|
this_element.start = 0;
|
||||||
@@ -291,6 +293,7 @@ function addPlaylist(arr, guid, offline, socket) {
|
|||||||
_db.close();
|
_db.close();
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Search.get_genres_list_recursive(arr.songs, channel);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -428,6 +431,7 @@ function add_function(arr, coll, guid, offline, socket) {
|
|||||||
var hash = arr.adminpass;
|
var hash = arr.adminpass;
|
||||||
var duration = parseInt(arr.duration);
|
var duration = parseInt(arr.duration);
|
||||||
var source = arr.source;
|
var source = arr.source;
|
||||||
|
var tags = arr.tags;
|
||||||
conf = docs;
|
conf = docs;
|
||||||
if(docs !== null && docs.length !== 0 && ((docs[0].addsongs === true && (hash == docs[0].adminpass || docs[0].adminpass === "")) ||
|
if(docs !== null && docs.length !== 0 && ((docs[0].addsongs === true && (hash == docs[0].adminpass || docs[0].adminpass === "")) ||
|
||||||
docs[0].addsongs === false)) {
|
docs[0].addsongs === false)) {
|
||||||
@@ -442,7 +446,7 @@ function add_function(arr, coll, guid, offline, socket) {
|
|||||||
} else {
|
} else {
|
||||||
np = false;
|
np = false;
|
||||||
}
|
}
|
||||||
var new_song = {"added": added,"guids":guids,"id":id,"now_playing":np,"title":title,"votes":votes, "duration":duration, "start": parseInt(start), "end": parseInt(end), "type": "video", "source": source};
|
var new_song = {"added": added,"guids":guids,"id":id,"now_playing":np,"title":title,"tags":tags,"votes":votes, "duration":duration, "start": parseInt(start), "end": parseInt(end), "type": "video", "source": source};
|
||||||
if(source == "soundcloud") {
|
if(source == "soundcloud") {
|
||||||
if(arr.thumbnail.indexOf("https://i1.sndcdn.com") > -1 || arr.thumbnail.indexOf("https://w1.sndcdn.com") > -1) {
|
if(arr.thumbnail.indexOf("https://i1.sndcdn.com") > -1 || arr.thumbnail.indexOf("https://w1.sndcdn.com") > -1) {
|
||||||
new_song.thumbnail = arr.thumbnail;
|
new_song.thumbnail = arr.thumbnail;
|
||||||
@@ -459,9 +463,11 @@ function add_function(arr, coll, guid, offline, socket) {
|
|||||||
var thumbnail = arr.thumbnail != undefined ? arr.thumbnail : undefined;
|
var thumbnail = arr.thumbnail != undefined ? arr.thumbnail : undefined;
|
||||||
Frontpage.update_frontpage(coll, id, title, thumbnail, arr.source);
|
Frontpage.update_frontpage(coll, id, title, thumbnail, arr.source);
|
||||||
if(source != "soundcloud") Search.get_correct_info(new_song, coll, false);
|
if(source != "soundcloud") Search.get_correct_info(new_song, coll, false);
|
||||||
|
else if(source == "soundcloud") Search.get_genres_soundcloud(new_song, coll);
|
||||||
} else {
|
} else {
|
||||||
io.to(coll).emit("channel", {type: "added", value: new_song});
|
io.to(coll).emit("channel", {type: "added", value: new_song});
|
||||||
if(source != "soundcloud") Search.get_correct_info(new_song, coll, true);
|
if(source != "soundcloud") Search.get_correct_info(new_song, coll, true);
|
||||||
|
else if(source == "soundcloud") Search.get_genres_soundcloud(new_song, coll);
|
||||||
}
|
}
|
||||||
db.collection("frontpage_lists").update({_id:coll}, {$inc:{count:1}, $set:{accessed: Functions.get_time()}}, {upsert:true}, function(err, docs){});
|
db.collection("frontpage_lists").update({_id:coll}, {$inc:{count:1}, $set:{accessed: Functions.get_time()}}, {upsert:true}, function(err, docs){});
|
||||||
List.getNextSong(coll, undefined);
|
List.getNextSong(coll, undefined);
|
||||||
@@ -485,7 +491,8 @@ function add_function(arr, coll, guid, offline, socket) {
|
|||||||
"duration":duration,
|
"duration":duration,
|
||||||
"start": start,
|
"start": start,
|
||||||
"end": end,
|
"end": end,
|
||||||
"type":"suggested"
|
"type":"suggested",
|
||||||
|
"tags":tags
|
||||||
};
|
};
|
||||||
var source = arr.source;
|
var source = arr.source;
|
||||||
if(source == "soundcloud") {
|
if(source == "soundcloud") {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ var time_regex = /P((([0-9]*\.?[0-9]*)Y)?(([0-9]*\.?[0-9]*)M)?(([0-9]*\.?[0-9]*)
|
|||||||
try {
|
try {
|
||||||
var keys = require(path.join(__dirname, '../config/api_key.js'));
|
var keys = require(path.join(__dirname, '../config/api_key.js'));
|
||||||
var key = keys.youtube;
|
var key = keys.youtube;
|
||||||
|
var soundcloudKey = keys.soundcloud;
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
console.log("Error - missing file");
|
console.log("Error - missing file");
|
||||||
console.log("Seems you forgot to create the file api_key.js in /server/config/. Have a look at api_key.example.js.");
|
console.log("Seems you forgot to create the file api_key.js in /server/config/. Have a look at api_key.example.js.");
|
||||||
@@ -11,11 +12,229 @@ try {
|
|||||||
var request = require('request');
|
var request = require('request');
|
||||||
var db = require(pathThumbnails + '/handlers/db.js');
|
var db = require(pathThumbnails + '/handlers/db.js');
|
||||||
|
|
||||||
|
function filterFunction(el) {
|
||||||
|
return el != null &&
|
||||||
|
el != "" &&
|
||||||
|
el != undefined &&
|
||||||
|
el.trim() != ''
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_genres_soundcloud(song, channel) {
|
||||||
|
request("http://api.soundcloud.com/tracks/" + song.id + "?client_id=" + soundcloudKey, function(err, response, body) {
|
||||||
|
if(err) {
|
||||||
|
console.log("error start", err, song, "error end");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
var object = JSON.parse(body);
|
||||||
|
if(!object.hasOwnProperty("genre") || !object.hasOwnProperty("tag_list")) return;
|
||||||
|
var genre = object.genre + ",";
|
||||||
|
genre = genre.toLowerCase().split(",").concat(object.tag_list.toLowerCase().split('"'));
|
||||||
|
genre = genre.filter(filterFunction);
|
||||||
|
|
||||||
|
db.collection(channel).update({"id": song.id}, {
|
||||||
|
$set: {
|
||||||
|
"tags": genre
|
||||||
|
}
|
||||||
|
}, function(e,d) {
|
||||||
|
|
||||||
|
});
|
||||||
|
} catch(e) {
|
||||||
|
console.log("errored 2", e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_genres_list(list, channel) {
|
||||||
|
var youtube_array = "";
|
||||||
|
var i = 0;
|
||||||
|
try {
|
||||||
|
for(var i = 0; i < list.length; i++) {
|
||||||
|
|
||||||
|
if(!list[i].hasOwnProperty("id")) continue;
|
||||||
|
if(list[i].source == undefined || list[i].source == "youtube") {
|
||||||
|
youtube_array += list[i].id + ",";
|
||||||
|
}
|
||||||
|
else if(list[i].source != undefined && list[i].source == "soundcloud") {
|
||||||
|
get_genres_soundcloud(list[i], channel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(youtube_array.length > 0) {
|
||||||
|
if(youtube_array > 49) {
|
||||||
|
var subList = [];
|
||||||
|
for(var i = 0; i < youtube_array.length; i++) {
|
||||||
|
subList.push(youtube_array[i]);
|
||||||
|
if(subList.length > 49) {
|
||||||
|
get_genres_youtube(subList.join(","), channel);
|
||||||
|
subList = [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
get_genres_youtube(subList.join(","), channel);
|
||||||
|
subList = [];
|
||||||
|
} else {
|
||||||
|
get_genres_youtube(youtube_array, channel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch(e) {
|
||||||
|
console.log("errored", e);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function start_soundcloud_get(arr, channel, callback) {
|
||||||
|
get_genres_soundcloud_recursive(arr, channel, 0, callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_genres_soundcloud_recursive(arr, channel, i, callback) {
|
||||||
|
if(i >= arr.length) {
|
||||||
|
if(typeof(callback) == "function") callback();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var song = arr[i];
|
||||||
|
request("http://api.soundcloud.com/tracks/" + song.id + "?client_id=" + soundcloudKey, function(err, response, body) {
|
||||||
|
if(err) {
|
||||||
|
console.log("error start", err, song, "error end");
|
||||||
|
get_genres_soundcloud_recursive(arr, channel, i + 1, callback);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
var object = JSON.parse(body);
|
||||||
|
if(!object.hasOwnProperty("genre") || !object.hasOwnProperty("tag_list")) {
|
||||||
|
get_genres_soundcloud_recursive(arr, channel, i + 1, callback);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var genre = object.genre + ",";
|
||||||
|
genre = genre.toLowerCase().split(",").concat(object.tag_list.toLowerCase().split('"'));
|
||||||
|
genre = genre.filter(filterFunction);
|
||||||
|
|
||||||
|
db.collection(channel).update({"id": song.id}, {
|
||||||
|
$set: {
|
||||||
|
"tags": genre
|
||||||
|
}
|
||||||
|
}, function(e,d) {
|
||||||
|
get_genres_soundcloud_recursive(arr, channel, i + 1, callback);
|
||||||
|
});
|
||||||
|
} catch(e) {
|
||||||
|
console.log("errored 2", e);
|
||||||
|
get_genres_soundcloud_recursive(arr, channel, i + 1, callback);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_genres_list_recursive(list, channel, callback) {
|
||||||
|
var youtube_array = [];
|
||||||
|
var soundcloud_array = [];
|
||||||
|
for(var i = 0; i < list.length; i++) {
|
||||||
|
if(!list[i].hasOwnProperty("id")) continue;
|
||||||
|
if(list[i].source == undefined || list[i].source == "youtube") {
|
||||||
|
youtube_array.push(list[i]);
|
||||||
|
}
|
||||||
|
else if(list[i].source != undefined && list[i].source == "soundcloud") {
|
||||||
|
soundcloud_array.push(list[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
start_youtube_get(youtube_array, channel, function() {
|
||||||
|
start_soundcloud_get(soundcloud_array, channel, function() {
|
||||||
|
if(typeof(callback) == "function") callback();
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function start_youtube_get(arr, channel, callback) {
|
||||||
|
get_genres_youtube_recursive(arr, channel, 0, callback)
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_genres_youtube_recursive(arr, channel, i, callback) {
|
||||||
|
if(i >= arr.length) {
|
||||||
|
if(typeof(callback) == "function") callback();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var ids = [];
|
||||||
|
for(var y = i; y < arr.length; y++) {
|
||||||
|
if(ids.length >= 48) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
ids.push(arr[y].id);
|
||||||
|
}
|
||||||
|
request({
|
||||||
|
type: "GET",
|
||||||
|
url: "https://www.googleapis.com/youtube/v3/videos?part=contentDetails,snippet,id,topicDetails&key="+key+"&id=" + ids.join(","),
|
||||||
|
}, function(error, response, body) {
|
||||||
|
if(error) {
|
||||||
|
console.log(arr, channel, i, arr[i]);
|
||||||
|
console.log("error start 1", error, ids, "error end");
|
||||||
|
get_genres_youtube_recursive(arr, channel, i + ids.length, callback);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var resp = JSON.parse(body);
|
||||||
|
if(!resp.hasOwnProperty("items")) {
|
||||||
|
console.log("error start 2", resp, ids, "error end");
|
||||||
|
get_genres_youtube_recursive(arr, channel, i + ids.length, callback);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(resp.items.length > 0) {
|
||||||
|
for(var z = 0; z < resp.items.length; z++) {
|
||||||
|
if(!resp.items[z].hasOwnProperty("topicDetails")) continue;
|
||||||
|
var genre = resp.items[z].topicDetails.topicCategories;
|
||||||
|
genre = genre.join(",");
|
||||||
|
genre = genre.replace(new RegExp("https://en.wikipedia.org/wiki/", "g"), "");
|
||||||
|
genre = genre.replace(/_/g, " ").toLowerCase().split(",");
|
||||||
|
genre = genre.filter(filterFunction);
|
||||||
|
//console.log(resp.items[i].id + " - ", genre);
|
||||||
|
db.collection(channel).update({"id": resp.items[z].id}, {
|
||||||
|
$set: {
|
||||||
|
"tags": genre
|
||||||
|
}
|
||||||
|
}, function(e, d) {
|
||||||
|
});
|
||||||
|
}
|
||||||
|
get_genres_youtube_recursive(arr, channel, i + ids.length, callback);
|
||||||
|
} else {
|
||||||
|
get_genres_youtube_recursive(arr, channel, i + ids.length, callback);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function get_genres_youtube(ids, channel) {
|
||||||
|
request({
|
||||||
|
type: "GET",
|
||||||
|
url: "https://www.googleapis.com/youtube/v3/videos?part=contentDetails,snippet,id,topicDetails&key="+key+"&id=" + ids,
|
||||||
|
}, function(error, response, body) {
|
||||||
|
if(error) {
|
||||||
|
console.log("error start", error, ids, "error end");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var resp = JSON.parse(body);
|
||||||
|
if(!resp.hasOwnProperty("items")) {
|
||||||
|
console.log("error start", resp, ids, "error end");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(resp.items.length > 0) {
|
||||||
|
for(var i = 0; i < resp.items.length; i++) {
|
||||||
|
if(!resp.items[i].hasOwnProperty("topicDetails")) continue;
|
||||||
|
var genre = resp.items[i].topicDetails.topicCategories;
|
||||||
|
genre = genre.join(",");
|
||||||
|
genre = genre.replace(new RegExp("https://en.wikipedia.org/wiki/", "g"), "");
|
||||||
|
genre = genre.replace(/_/g, " ").toLowerCase().split(",");
|
||||||
|
genre = genre.filter(filterFunction);
|
||||||
|
//console.log(resp.items[i].id + " - ", genre);
|
||||||
|
db.collection(channel).update({"id": resp.items[i].id}, {
|
||||||
|
$set: {
|
||||||
|
"tags": genre
|
||||||
|
}
|
||||||
|
}, function(e, d) {});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function get_correct_info(song_generated, channel, broadcast, callback) {
|
function get_correct_info(song_generated, channel, broadcast, callback) {
|
||||||
//channel = channel.replace(/ /g,'');
|
//channel = channel.replace(/ /g,'');
|
||||||
request({
|
request({
|
||||||
type: "GET",
|
type: "GET",
|
||||||
url: "https://www.googleapis.com/youtube/v3/videos?part=contentDetails,snippet,id&key="+key+"&id=" + song_generated.id,
|
url: "https://www.googleapis.com/youtube/v3/videos?part=contentDetails,snippet,id,topicDetails&key="+key+"&id=" + song_generated.id,
|
||||||
|
|
||||||
}, function(error, response, body) {
|
}, function(error, response, body) {
|
||||||
try {
|
try {
|
||||||
@@ -23,6 +242,12 @@ function get_correct_info(song_generated, channel, broadcast, callback) {
|
|||||||
if(resp.items.length == 1) {
|
if(resp.items.length == 1) {
|
||||||
var duration = parseInt(durationToSeconds(resp.items[0].contentDetails.duration));
|
var duration = parseInt(durationToSeconds(resp.items[0].contentDetails.duration));
|
||||||
var title = resp.items[0].snippet.localized.title;
|
var title = resp.items[0].snippet.localized.title;
|
||||||
|
var genre = resp.items[0].topicDetails.topicCategories;
|
||||||
|
genre = genre.join(",");
|
||||||
|
genre = genre.replace(new RegExp("https://en.wikipedia.org/wiki/", "g"), "");
|
||||||
|
genre = genre.replace(/_/g, " ").toLowerCase().split(",");
|
||||||
|
genre = genre.filter(filterFunction);
|
||||||
|
//console.log(genre + " - ", song_generated.id);
|
||||||
if(title != song_generated.title || duration < parseInt(song_generated.duration)) {
|
if(title != song_generated.title || duration < parseInt(song_generated.duration)) {
|
||||||
if(title != song_generated.title) {
|
if(title != song_generated.title) {
|
||||||
song_generated.title = title;
|
song_generated.title = title;
|
||||||
@@ -38,6 +263,7 @@ function get_correct_info(song_generated, channel, broadcast, callback) {
|
|||||||
"start": song_generated.start,
|
"start": song_generated.start,
|
||||||
"end": song_generated.end,
|
"end": song_generated.end,
|
||||||
"title": song_generated.title,
|
"title": song_generated.title,
|
||||||
|
"tags": genre
|
||||||
}
|
}
|
||||||
}, function(err, docs) {
|
}, function(err, docs) {
|
||||||
if(broadcast && docs.nModified == 1) {
|
if(broadcast && docs.nModified == 1) {
|
||||||
@@ -55,9 +281,15 @@ function get_correct_info(song_generated, channel, broadcast, callback) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
db.collection(channel).update({"id": song_generated.id}, {
|
||||||
|
$set: {
|
||||||
|
"tags": genre
|
||||||
|
}
|
||||||
|
}, function(e,d) {
|
||||||
if(typeof(callback) == "function") {
|
if(typeof(callback) == "function") {
|
||||||
callback(song_generated, true);
|
callback(song_generated, true);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
findSimilar(song_generated, channel, broadcast, callback)
|
findSimilar(song_generated, channel, broadcast, callback)
|
||||||
@@ -213,5 +445,9 @@ function durationToSeconds(duration) {
|
|||||||
return hours*60*60+minutes*60+seconds;
|
return hours*60*60+minutes*60+seconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
module.exports.get_genres_list_recursive = get_genres_list_recursive;
|
||||||
|
module.exports.get_genres_soundcloud = get_genres_soundcloud;
|
||||||
|
module.exports.get_genres_youtube = get_genres_youtube;
|
||||||
|
module.exports.get_genres_list = get_genres_list;
|
||||||
module.exports.check_error_video = check_error_video;
|
module.exports.check_error_video = check_error_video;
|
||||||
module.exports.get_correct_info = get_correct_info;
|
module.exports.get_correct_info = get_correct_info;
|
||||||
|
|||||||
@@ -376,8 +376,26 @@ li.disabled span {
|
|||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
color: white;
|
color: #fff;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
padding-right: 7px;
|
||||||
|
margin-left: -7px;
|
||||||
|
margin-top: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-pagination-container {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-evenly;
|
||||||
|
width: 50%;
|
||||||
|
margin: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bottom-filter-container {
|
||||||
|
padding-top: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.top-filter-container {
|
||||||
|
padding-bottom: 15px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.extra-button{
|
.extra-button{
|
||||||
@@ -1180,7 +1198,7 @@ margin:-1px;
|
|||||||
padding-left: 8px;
|
padding-left: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#close_find_form_button {
|
#close_find_form_button, #open_advanced_filter {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-self: center;
|
align-self: center;
|
||||||
padding-left: 10px;
|
padding-left: 10px;
|
||||||
@@ -2109,6 +2127,10 @@ nav ul li:hover, nav ul li.active {
|
|||||||
height:66px;
|
height:66px;
|
||||||
margin: 2.5px 0 2.5px -1px !important;
|
margin: 2.5px 0 2.5px -1px !important;
|
||||||
}
|
}
|
||||||
|
.filtered-search-element {
|
||||||
|
background-color: #2d2d2d;
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
.card:hover{
|
.card:hover{
|
||||||
box-shadow: 0 5px 5px 0 rgba(0,0,0,0.16), 0 5px 10px 0 rgba(0,0,0,0.12);
|
box-shadow: 0 5px 5px 0 rgba(0,0,0,0.16), 0 5px 10px 0 rgba(0,0,0,0.12);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -143,6 +143,16 @@ var Channel = {
|
|||||||
Helper.removeElement(".embed-button-footer");
|
Helper.removeElement(".embed-button-footer");
|
||||||
Helper.removeElement(".tabs");
|
Helper.removeElement(".tabs");
|
||||||
}
|
}
|
||||||
|
M.Modal.init(document.getElementById("advanced_filter"), {
|
||||||
|
onCloseEnd: function() {
|
||||||
|
document.querySelector(".filter-results").innerHTML = "";
|
||||||
|
document.getElementById("filtersearch_input").value = "";
|
||||||
|
document.getElementById("filtersearch_input").blur();
|
||||||
|
},
|
||||||
|
onOpenEnd: function() {
|
||||||
|
document.getElementById("filtersearch_input").focus();
|
||||||
|
}
|
||||||
|
});
|
||||||
M.Modal.init(document.getElementById("help"));
|
M.Modal.init(document.getElementById("help"));
|
||||||
M.Modal.init(document.getElementById("contact"));
|
M.Modal.init(document.getElementById("contact"));
|
||||||
M.Modal.init(document.getElementById("channel-share-modal"));
|
M.Modal.init(document.getElementById("channel-share-modal"));
|
||||||
|
|||||||
@@ -21,6 +21,56 @@ function removeAllListeners() {
|
|||||||
socket.removeEventListener(id);
|
socket.removeEventListener(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function filterPlaylistElements(page) {
|
||||||
|
Helper.ajax({
|
||||||
|
type: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json"
|
||||||
|
},
|
||||||
|
url: "/api/search/" + chan.toLowerCase(),
|
||||||
|
data: {
|
||||||
|
searchQuery: document.getElementById("filtersearch_input").value,
|
||||||
|
token: zoff_api_token,
|
||||||
|
page: page
|
||||||
|
},
|
||||||
|
success: function(data){
|
||||||
|
var json = JSON.parse(data);
|
||||||
|
document.querySelector(".filter-results").innerHTML = "";
|
||||||
|
if(json.results.search_results.length > 0) {
|
||||||
|
addFilterButtons("top", json);
|
||||||
|
for(var i = 0; i < json.results.search_results.length; i++) {
|
||||||
|
document.querySelector(".filter-results").innerHTML += List.generateSong(json.results.search_results[i], false, false, true, false, "block", false, true);;
|
||||||
|
}
|
||||||
|
addFilterButtons("bottom", json);
|
||||||
|
} else {
|
||||||
|
toast("Couldn't find any items with those tags..", "red");
|
||||||
|
document.querySelector(".filter-results").innerHTML = "Couldn't find any items with those tags..";
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function() {
|
||||||
|
toast("Couldn't find any items with those tags..", "red");
|
||||||
|
|
||||||
|
document.querySelector(".filter-results").innerHTML = "Couldn't find any items with those tags..";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function addFilterButtons(position, json) {
|
||||||
|
if(json.results.next != undefined || json.results.prev != undefined) {
|
||||||
|
document.querySelector(".filter-results").innerHTML += "<div class='filter-pagination-container " + position + "-filter-container'></div>"
|
||||||
|
if(json.results.prev != undefined) {
|
||||||
|
document.querySelector("." + position + "-filter-container").innerHTML += "<a href='#' class='btn orange prev-filter' data-page='" + json.results.prev + "'>Prev</a>";
|
||||||
|
} else {
|
||||||
|
document.querySelector("." + position + "-filter-container").innerHTML += "<a href='#' class='btn orange disabled'>Prev</a>";
|
||||||
|
}
|
||||||
|
if(json.results.next != undefined) {
|
||||||
|
document.querySelector("." + position + "-filter-container").innerHTML += "<a href='#' class='btn orange next-filter' data-page='" + json.results.next + "'>Next</a>";
|
||||||
|
} else {
|
||||||
|
document.querySelector("." + position + "-filter-container").innerHTML += "<a href='#' class='btn orange disabled'>Next</a>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function say_updated() {
|
function say_updated() {
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
before_toast();
|
before_toast();
|
||||||
|
|||||||
@@ -1242,7 +1242,7 @@ var List = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
generateSong: function(_song_info, transition, lazy, list, user, display, initial) {
|
generateSong: function(_song_info, transition, lazy, list, user, display, initial, filtered) {
|
||||||
if(list_html === undefined) list_html = Helper.html("#list-song-html");
|
if(list_html === undefined) list_html = Helper.html("#list-song-html");
|
||||||
var video_id = _song_info.id;
|
var video_id = _song_info.id;
|
||||||
var video_title = _song_info.title;
|
var video_title = _song_info.title;
|
||||||
@@ -1275,8 +1275,8 @@ var List = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
song.querySelector(".list-image").setAttribute(image_attr,video_thumb);
|
song.querySelector(".list-image").setAttribute(image_attr,video_thumb);
|
||||||
if(list){
|
if(list && !filtered){
|
||||||
song.querySelector("#list-song")
|
//song.querySelector("#list-song")
|
||||||
song.querySelector(".list-votes").innerText = video_votes;
|
song.querySelector(".list-votes").innerText = video_votes;
|
||||||
song.querySelector("#list-song").setAttribute("data-video-id", video_id);
|
song.querySelector("#list-song").setAttribute("data-video-id", video_id);
|
||||||
song.querySelector("#list-song").setAttribute("data-video-type", "song");
|
song.querySelector("#list-song").setAttribute("data-video-type", "song");
|
||||||
@@ -1292,7 +1292,7 @@ var List = {
|
|||||||
|
|
||||||
var _temp_duration = Helper.secondsToOther(_song_info.duration);
|
var _temp_duration = Helper.secondsToOther(_song_info.duration);
|
||||||
song.querySelector(".card-duration").innerText = Helper.pad(_temp_duration[0]) + ":" + Helper.pad(_temp_duration[1]);
|
song.querySelector(".card-duration").innerText = Helper.pad(_temp_duration[0]) + ":" + Helper.pad(_temp_duration[1]);
|
||||||
}else if(!list){
|
}else if(!list && !filtered){
|
||||||
|
|
||||||
//song.querySelector(".card-duration").remove();
|
//song.querySelector(".card-duration").remove();
|
||||||
//song.querySelector(".list-song").removeClass("playlist-element");
|
//song.querySelector(".list-song").removeClass("playlist-element");
|
||||||
@@ -1329,6 +1329,22 @@ var List = {
|
|||||||
list_image.classList.remove("list-image");
|
list_image.classList.remove("list-image");
|
||||||
list_image.className += " list-suggested-image";
|
list_image.className += " list-suggested-image";
|
||||||
//song.querySelector(".list-image").setAttribute("class", song.querySelector(".list-image").getAttribute("class").replace("list-image", "list-suggested-image"));
|
//song.querySelector(".list-image").setAttribute("class", song.querySelector(".list-image").getAttribute("class").replace("list-image", "list-suggested-image"));
|
||||||
|
} else if(filtered) {
|
||||||
|
song.querySelector("#list-song").className += " filtered-search-element";
|
||||||
|
song.querySelector(".list-votes").innerText = _song_info.tags.join(", ");
|
||||||
|
song.querySelector(".vote-text").remove();
|
||||||
|
song.querySelector("#list-song").setAttribute("data-video-id", video_id);
|
||||||
|
song.querySelector("#list-song").setAttribute("data-video-type", "song");
|
||||||
|
song.querySelector("#list-song").setAttribute("data-video-source", _song_info.source);
|
||||||
|
song.querySelector("#list-song").setAttribute("id", "filtered-" + video_id);
|
||||||
|
song.classList.remove("hide");
|
||||||
|
song.className += " filtered-search-element";
|
||||||
|
song.querySelector(".vote-container").setAttribute("title", video_title);
|
||||||
|
attr = ".vote-container";
|
||||||
|
del_attr = "delete_button";
|
||||||
|
|
||||||
|
var _temp_duration = Helper.secondsToOther(_song_info.duration);
|
||||||
|
song.querySelector(".card-duration").innerText = Helper.pad(_temp_duration[0]) + ":" + Helper.pad(_temp_duration[1]);
|
||||||
}
|
}
|
||||||
if(!embed) {
|
if(!embed) {
|
||||||
song.querySelector(".mobile-delete").remove();
|
song.querySelector(".mobile-delete").remove();
|
||||||
|
|||||||
@@ -682,13 +682,51 @@ function addDynamicListeners() {
|
|||||||
this.preventDefault();
|
this.preventDefault();
|
||||||
Helper.toggleClass("#find_div", "hide");
|
Helper.toggleClass("#find_div", "hide");
|
||||||
document.getElementById("find_input").value = "";
|
document.getElementById("find_input").value = "";
|
||||||
document.getElementById("find_input").blur();
|
document.getElementById("find_input").focus();
|
||||||
Helper.removeClass(".highlight", "highlight");
|
Helper.removeClass(".highlight", "highlight");
|
||||||
found_array = [];
|
found_array = [];
|
||||||
found_array_index = 0;
|
found_array_index = 0;
|
||||||
find_word = "";
|
find_word = "";
|
||||||
});
|
});
|
||||||
|
|
||||||
|
addListener("click", "#open_advanced_filter", function(e) {
|
||||||
|
this.preventDefault();
|
||||||
|
M.Modal.getInstance(document.getElementById("advanced_filter")).open();
|
||||||
|
ga('send', 'event', "button-click", "advanced_filter");
|
||||||
|
});
|
||||||
|
|
||||||
|
addListener("submit", "#filter-form", function(e) {
|
||||||
|
this.preventDefault();
|
||||||
|
filterPlaylistElements(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
addListener("click", ".submit-filter-search", function(e) {
|
||||||
|
this.preventDefault();
|
||||||
|
filterPlaylistElements(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
addListener("click", ".next-filter", function(e) {
|
||||||
|
this.preventDefault();
|
||||||
|
var page = e.getAttribute("data-page");
|
||||||
|
page = parseInt(page);
|
||||||
|
if(page == undefined || isNaN(page)) return;
|
||||||
|
e.classList.remove("next-filter");
|
||||||
|
e.classList.remove("orange");
|
||||||
|
e.className += " disabled";
|
||||||
|
filterPlaylistElements(page);
|
||||||
|
});
|
||||||
|
|
||||||
|
addListener("click", ".prev-filter", function(e) {
|
||||||
|
this.preventDefault();
|
||||||
|
var page = e.getAttribute("data-page");
|
||||||
|
page = parseInt(page);
|
||||||
|
if(page == undefined || isNaN(page)) return;
|
||||||
|
e.classList.remove("prev-filter");
|
||||||
|
e.classList.remove("orange");
|
||||||
|
e.className += " disabled";
|
||||||
|
filterPlaylistElements(page);
|
||||||
|
});
|
||||||
|
|
||||||
addListener("click", ".delete-context-menu", function(e) {
|
addListener("click", ".delete-context-menu", function(e) {
|
||||||
var that = e;
|
var that = e;
|
||||||
if(that.classList.contains("context-menu-disabled")) {
|
if(that.classList.contains("context-menu-disabled")) {
|
||||||
@@ -1600,9 +1638,9 @@ function addDynamicListeners() {
|
|||||||
this.stopPropagation();
|
this.stopPropagation();
|
||||||
var id = e.getAttribute("data-video-id");
|
var id = e.getAttribute("data-video-id");
|
||||||
var title = e.getAttribute("data-video-title");
|
var title = e.getAttribute("data-video-title");
|
||||||
|
|
||||||
var original_length = e.getAttribute("data-video-length");
|
var original_length = e.getAttribute("data-video-length");
|
||||||
var parent = e.parentElement.parentElement;
|
var parent = e.parentElement.parentElement;
|
||||||
|
|
||||||
var start = parseInt(parent.querySelectorAll(".result-start")[0].value);
|
var start = parseInt(parent.querySelectorAll(".result-start")[0].value);
|
||||||
var end = parseInt(parent.querySelectorAll(".result-end")[0].value);
|
var end = parseInt(parent.querySelectorAll(".result-end")[0].value);
|
||||||
if(end > original_length) {
|
if(end > original_length) {
|
||||||
|
|||||||
@@ -48,11 +48,12 @@ var Search = {
|
|||||||
yt_url+="&q="+keyword;
|
yt_url+="&q="+keyword;
|
||||||
if(music)yt_url+="&videoCategoryId=10";
|
if(music)yt_url+="&videoCategoryId=10";
|
||||||
if(pagination) yt_url += "&pageToken=" + pagination;
|
if(pagination) yt_url += "&pageToken=" + pagination;
|
||||||
var vid_url = "https://www.googleapis.com/youtube/v3/videos?part=contentDetails,snippet,id&key="+api_key.youtube+"&id=";
|
var vid_url = "https://www.googleapis.com/youtube/v3/videos?part=contentDetails,snippet,id&fields=pageInfo,items(id,contentDetails,snippet(categoryId,channelTitle,publishedAt,title,description,thumbnails))&key="+api_key.youtube+"&id=";
|
||||||
if(related) {
|
if(related) {
|
||||||
var yt_url = "https://www.googleapis.com/youtube/v3/search?part=snippet&maxResults=25&relatedToVideoId="+keyword+"&type=video&key="+api_key.youtube;
|
var yt_url = "https://www.googleapis.com/youtube/v3/search?part=snippet&maxResults=25&relatedToVideoId="+keyword+"&type=video&key="+api_key.youtube;
|
||||||
var vid_url = "https://www.googleapis.com/youtube/v3/videos?part=contentDetails,snippet,id&key="+api_key.youtube+"&id=";
|
var vid_url = "https://www.googleapis.com/youtube/v3/videos?part=contentDetails,snippet,id&key="+api_key.youtube+"&id=";
|
||||||
}
|
}
|
||||||
|
//https://www.googleapis.com/youtube/v3/videos?key={API-key}&fields=items(snippet(title,description))&part=snippet&id={video_id}
|
||||||
|
|
||||||
Helper.addClass(document.querySelector("#search-btn .material-icons"), "hide");
|
Helper.addClass(document.querySelector("#search-btn .material-icons"), "hide");
|
||||||
Helper.removeClass("#search_loader", "hide");
|
Helper.removeClass("#search_loader", "hide");
|
||||||
@@ -90,6 +91,7 @@ var Search = {
|
|||||||
dataType:"jsonp",
|
dataType:"jsonp",
|
||||||
success: function(response){
|
success: function(response){
|
||||||
response = JSON.parse(response);
|
response = JSON.parse(response);
|
||||||
|
console.log(response);
|
||||||
var output = "";
|
var output = "";
|
||||||
var pre_result = document.createElement("div");
|
var pre_result = document.createElement("div");
|
||||||
pre_result.innerHTML = result_html.outerHTML;
|
pre_result.innerHTML = result_html.outerHTML;
|
||||||
@@ -106,7 +108,6 @@ var Search = {
|
|||||||
var id=song.id;
|
var id=song.id;
|
||||||
duration = duration.replace("PT","").replace("H","h ").replace("M","m ").replace("S","s");
|
duration = duration.replace("PT","").replace("H","h ").replace("M","m ").replace("S","s");
|
||||||
var thumb=song.snippet.thumbnails.medium.url;
|
var thumb=song.snippet.thumbnails.medium.url;
|
||||||
|
|
||||||
//$("#results").append(result_html);
|
//$("#results").append(result_html);
|
||||||
var songs = pre_result.cloneNode(true);
|
var songs = pre_result.cloneNode(true);
|
||||||
songs.querySelector(".search-title").innerText = title;
|
songs.querySelector(".search-title").innerText = title;
|
||||||
@@ -208,7 +209,7 @@ var Search = {
|
|||||||
}).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;
|
||||||
|
console.log(tracks);
|
||||||
//$("#results").append(result_html);
|
//$("#results").append(result_html);
|
||||||
//Helper.css(document.querySelector(".search_results .col.s12"), "display", "block");
|
//Helper.css(document.querySelector(".search_results .col.s12"), "display", "block");
|
||||||
var output = "";
|
var output = "";
|
||||||
@@ -655,14 +656,36 @@ submit: function(id,title,duration, playlist, num, full_num, start, end, source,
|
|||||||
if(full_playlist[i].id == id) found_array.push(i);
|
if(full_playlist[i].id == id) found_array.push(i);
|
||||||
}
|
}
|
||||||
if(found_array.length == 0){
|
if(found_array.length == 0){
|
||||||
List.channel_function({type: "added", start: start, end: end, value: {added: (new Date).getTime()/1000, guids: [1], id: id, title: title, duration: duration, now_playing: false, votes: 1}});
|
List.channel_function({
|
||||||
|
type: "added",
|
||||||
|
start: start,
|
||||||
|
end: end,
|
||||||
|
value: {
|
||||||
|
added: (new Date).getTime()/1000,
|
||||||
|
guids: [1],
|
||||||
|
id: id,
|
||||||
|
title: title,
|
||||||
|
duration: duration,
|
||||||
|
now_playing: false,
|
||||||
|
votes: 1
|
||||||
|
}
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
List.vote(id, "pos");
|
List.vote(id, "pos");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/*var u = Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()), true);
|
/*var u = Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()), true);
|
||||||
if(u == undefined) u = "";*/
|
if(u == undefined) u = "";*/
|
||||||
emit("add", {id: id, start: start, end: end, title: title, list: chan.toLowerCase(), duration: duration, source: source, thumbnail: thumbnail});
|
emit("add", {
|
||||||
|
id: id,
|
||||||
|
start: start,
|
||||||
|
end: end,
|
||||||
|
title: title,
|
||||||
|
list: chan.toLowerCase(),
|
||||||
|
duration: duration,
|
||||||
|
source: source,
|
||||||
|
thumbnail: thumbnail
|
||||||
|
});
|
||||||
}//[id, decodeURIComponent(title), adminpass, duration, playlist]);
|
}//[id, decodeURIComponent(title), adminpass, duration, playlist]);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ var Suggestions = {
|
|||||||
Helper.removeClass("#suggest-song-html", "hide");
|
Helper.removeClass("#suggest-song-html", "hide");
|
||||||
}
|
}
|
||||||
var get_url = "https://www.googleapis.com/youtube/v3/search?part=snippet&relatedToVideoId="+id+"&type=video&key="+api_key.youtube;
|
var get_url = "https://www.googleapis.com/youtube/v3/search?part=snippet&relatedToVideoId="+id+"&type=video&key="+api_key.youtube;
|
||||||
var video_urls = "https://www.googleapis.com/youtube/v3/videos?part=contentDetails,snippet,id,statistics&key="+api_key.youtube+"&id=";
|
var video_urls = "https://www.googleapis.com/youtube/v3/videos?part=contentDetails,snippet,id,statistics&fields=pageInfo,items(id,contentDetails,snippet(categoryId,channelTitle,publishedAt,title,description,thumbnails))&key="+api_key.youtube+"&id=";
|
||||||
|
|
||||||
Helper.ajax({
|
Helper.ajax({
|
||||||
type: "GET",
|
type: "GET",
|
||||||
|
|||||||
@@ -39,6 +39,23 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{/unless}}
|
{{/unless}}
|
||||||
|
<div id="advanced_filter" class="modal modal-fixed-footer">
|
||||||
|
<div class="modal-content">
|
||||||
|
<h4>Advanced</h4>
|
||||||
|
<p>Here you can search by category. Keep in mind, this uses the category/genre/tags defined by the uploader of the video on YouTube or the song on SoundCloud</p>
|
||||||
|
<div class="row container">
|
||||||
|
<form id="filter-form">
|
||||||
|
<input type="text" class="col s8 m9" name="filtersearch_value" placeholder="Find.." id="filtersearch_input" autocomplete="off" />
|
||||||
|
<a href="#" class="waves-effect waves-light btn col s4 m2 orange submit-filter-search">Search</a>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<div class="filter-results">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<a href="#!" class=" modal-action modal-close waves-effect waves-green btn-flat">Close</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div id="help" class="modal modal-fixed-footer">
|
<div id="help" class="modal modal-fixed-footer">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<h4>Help</h4>
|
<h4>Help</h4>
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
<div class="num_of_found">
|
<div class="num_of_found">
|
||||||
<span id="num_found">0</span>/<span id="of_total_found">0</span>
|
<span id="num_found">0</span>/<span id="of_total_found">0</span>
|
||||||
</div>
|
</div>
|
||||||
|
<a href="#" id="open_advanced_filter"><i class="material-icons">filter_list</i></a>
|
||||||
<a href="#" id="close_find_form_button"><i class="material-icons">clear</i></a>
|
<a href="#" id="close_find_form_button"><i class="material-icons">clear</i></a>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ var Search = require(pathThumbnails + '/handlers/search.js');
|
|||||||
var uniqid = require('uniqid');
|
var uniqid = require('uniqid');
|
||||||
var Filter = require('bad-words');
|
var Filter = require('bad-words');
|
||||||
var filter = new Filter({ placeHolder: 'x'});
|
var filter = new Filter({ placeHolder: 'x'});
|
||||||
|
var paginate = require('mongojs-paginate');
|
||||||
|
|
||||||
var _exports = {
|
var _exports = {
|
||||||
router: router,
|
router: router,
|
||||||
@@ -732,6 +733,105 @@ router.route('/api/list/:channel_name/__np__').post(function(req, res) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
router.route('/api/search/:channel_name/').post(function(req, res) {
|
||||||
|
res.header("Access-Control-Allow-Origin", "*");
|
||||||
|
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
|
||||||
|
res.header({"Content-Type": "application/json"});
|
||||||
|
try {
|
||||||
|
var ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress;
|
||||||
|
var guid = Functions.hash_pass(req.get('User-Agent') + ip + req.headers["accept-language"]);
|
||||||
|
var channel_name = cleanChannelName(req.params.channel_name);
|
||||||
|
var userpass;
|
||||||
|
if(req.body.hasOwnProperty("userpass")) {
|
||||||
|
req.body.userpass = req.body.userpass == "" ? "" : crypto.createHash('sha256').update(req.body.userpass, 'utf8').digest("base64");
|
||||||
|
userpass = req.body.userpass;
|
||||||
|
} else {
|
||||||
|
userpass = "";
|
||||||
|
}
|
||||||
|
var page = 1;
|
||||||
|
if(req.body.hasOwnProperty("page") && req.body.page > 0) {
|
||||||
|
page = req.body.page;
|
||||||
|
}
|
||||||
|
var searchQuery = "";
|
||||||
|
if(req.body.searchQuery == undefined || req.body.searchQuery == "") {
|
||||||
|
var to_send = error.formatting;
|
||||||
|
to_send.results = [result];
|
||||||
|
res.status(400).send(to_send);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
searchQuery = req.body.searchQuery.toLowerCase();
|
||||||
|
var token = "";
|
||||||
|
if(req.body.hasOwnProperty("token")) {
|
||||||
|
token = req.body.token;
|
||||||
|
}
|
||||||
|
} catch(e) {
|
||||||
|
var result = {
|
||||||
|
userpass: {
|
||||||
|
expected: "string",
|
||||||
|
got: req.body.hasOwnProperty("userpass") ? typeof(req.body.userpass) : undefined
|
||||||
|
}
|
||||||
|
};
|
||||||
|
var to_send = error.formatting;
|
||||||
|
to_send.results = [result];
|
||||||
|
res.status(400).send(to_send);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var cookie = req.cookies._uI;
|
||||||
|
Functions.getSessionAdminUser(cookie, channel_name, function(_u, _a) {
|
||||||
|
if(req.body.userpass == "") {
|
||||||
|
//userpass = Functions.hash_pass(Functions.hash_pass(Functions.decrypt_string(_u)))
|
||||||
|
userpass = _u;
|
||||||
|
}
|
||||||
|
token_db.collection("api_token").find({token: token}, function(err, token_docs) {
|
||||||
|
var authorized = false;
|
||||||
|
var origin;
|
||||||
|
try {
|
||||||
|
origin = req.headers.referer.split("/")[2];
|
||||||
|
} catch(e) { origin = ""; }
|
||||||
|
if(token_docs.length == 1 && token_docs[0].token == token && (token_docs[0].origin == "*" || origin.indexOf(token_docs[0].origin) > -1)) {
|
||||||
|
authorized = true;
|
||||||
|
}
|
||||||
|
checkOveruseApiToken(authorized, token_docs, res, function() {
|
||||||
|
checkTimeout(guid, res, authorized, "POST", function() {
|
||||||
|
db.collection(channel_name + "_settings").find({ id: "config" }, function(err, conf) {
|
||||||
|
if(authorized) {
|
||||||
|
incrementToken(token);
|
||||||
|
}
|
||||||
|
if(conf.length == 0) {
|
||||||
|
res.status(404).send(error.not_found.list);
|
||||||
|
return;
|
||||||
|
} else if(conf[0].userpass != userpass && conf[0].userpass != "" && conf[0].userpass != undefined) {
|
||||||
|
res.status(403).send(error.not_authenticated);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var query = db.collection(channel_name).find({tags: {
|
||||||
|
$regex : ".*" + searchQuery + ".*"
|
||||||
|
}});
|
||||||
|
paginate(query, { limit : 30, page : page }, function(err, result) {
|
||||||
|
if(result.items.length == 0) {
|
||||||
|
res.status(404).send(error.not_found.local);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var to_return = error.no_error
|
||||||
|
to_return.results = {};
|
||||||
|
if(result.hasNext) {
|
||||||
|
to_return.results.next = result.page + 1;
|
||||||
|
}
|
||||||
|
if(result.hasPrevious) {
|
||||||
|
to_return.results.prev = result.page - 1;
|
||||||
|
}
|
||||||
|
to_return.results.search_results = result.items;
|
||||||
|
|
||||||
|
res.status(200).send(to_return);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
router.route('/api/list/:channel_name/:video_id').post(function(req,res) {
|
router.route('/api/list/:channel_name/:video_id').post(function(req,res) {
|
||||||
res.header("Access-Control-Allow-Origin", "*");
|
res.header("Access-Control-Allow-Origin", "*");
|
||||||
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
|
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
|
||||||
@@ -770,6 +870,8 @@ router.route('/api/list/:channel_name/:video_id').post(function(req,res) {
|
|||||||
var duration = parseInt(req.body.duration);
|
var duration = parseInt(req.body.duration);
|
||||||
var start_time = parseInt(req.body.start_time);
|
var start_time = parseInt(req.body.start_time);
|
||||||
var end_time = parseInt(req.body.end_time);
|
var end_time = parseInt(req.body.end_time);
|
||||||
|
var tags = [];
|
||||||
|
if(req.body.tags != undefined) tags = req.body.tags.split(",");
|
||||||
var source = req.body.source;
|
var source = req.body.source;
|
||||||
if(source == "soundcloud" && !req.body.hasOwnProperty("thumbnail")) {
|
if(source == "soundcloud" && !req.body.hasOwnProperty("thumbnail")) {
|
||||||
throw "Wrong format";
|
throw "Wrong format";
|
||||||
@@ -852,7 +954,7 @@ router.route('/api/list/:channel_name/:video_id').post(function(req,res) {
|
|||||||
if(now_playing.length == 0 && authenticated) {
|
if(now_playing.length == 0 && authenticated) {
|
||||||
set_np = true;
|
set_np = true;
|
||||||
}
|
}
|
||||||
var new_song = {"added": Functions.get_time(),"guids":[guid],"id":video_id,"now_playing":set_np,"title":title,"votes":1, "duration":duration, "start": parseInt(start_time), "end": parseInt(end_time), "type": song_type, "source": source};
|
var new_song = {"tags": tags, "added": Functions.get_time(),"guids":[guid],"id":video_id,"now_playing":set_np,"title":title,"votes":1, "duration":duration, "start": parseInt(start_time), "end": parseInt(end_time), "type": song_type, "source": source};
|
||||||
var runFunction = Search.get_correct_info;
|
var runFunction = Search.get_correct_info;
|
||||||
if(source == "soundcloud") {
|
if(source == "soundcloud") {
|
||||||
if(req.body.thumbnail.indexOf("https://i1.sndcdn.com") > -1 || req.body.thumbnail.indexOf("https://w1.sndcdn.com") > -1) {
|
if(req.body.thumbnail.indexOf("https://i1.sndcdn.com") > -1 || req.body.thumbnail.indexOf("https://w1.sndcdn.com") > -1) {
|
||||||
|
|||||||
Reference in New Issue
Block a user