mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
Tags add for add songs and in api
This commit is contained in:
@@ -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;
|
||||||
@@ -425,6 +427,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)) {
|
||||||
@@ -439,7 +442,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;
|
||||||
@@ -482,7 +485,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") {
|
||||||
|
|||||||
@@ -1247,6 +1247,8 @@ var List = {
|
|||||||
var video_id = _song_info.id;
|
var video_id = _song_info.id;
|
||||||
var video_title = _song_info.title;
|
var video_title = _song_info.title;
|
||||||
var video_votes = _song_info.votes;
|
var video_votes = _song_info.votes;
|
||||||
|
var tags = "";
|
||||||
|
if(_song_info.tags != undefined) _song_info.tags.toLowerCase();
|
||||||
var video_thumb_url = "//img.youtube.com/vi/"+video_id+"/mqdefault.jpg";
|
var video_thumb_url = "//img.youtube.com/vi/"+video_id+"/mqdefault.jpg";
|
||||||
if(_song_info.source == "soundcloud") {
|
if(_song_info.source == "soundcloud") {
|
||||||
video_thumb_url = _song_info.thumbnail;
|
video_thumb_url = _song_info.thumbnail;
|
||||||
@@ -1316,6 +1318,7 @@ var List = {
|
|||||||
song.querySelector(attr).setAttribute("data-video-title", video_title);
|
song.querySelector(attr).setAttribute("data-video-title", video_title);
|
||||||
song.querySelector(attr).setAttribute("data-video-length", _song_info.length);
|
song.querySelector(attr).setAttribute("data-video-length", _song_info.length);
|
||||||
song.querySelector(attr).setAttribute("data-added-by", added_by);
|
song.querySelector(attr).setAttribute("data-added-by", added_by);
|
||||||
|
song.querySelector(attr).setAttribute("data-tags", tags);
|
||||||
song.querySelector(attr).setAttribute("data-video-type", "suggested");
|
song.querySelector(attr).setAttribute("data-video-type", "suggested");
|
||||||
if(_song_info.source == "soundcloud") {
|
if(_song_info.source == "soundcloud") {
|
||||||
song.querySelector(attr).setAttribute("data-type-thumbnail", _song_info.thumbnail);
|
song.querySelector(attr).setAttribute("data-type-thumbnail", _song_info.thumbnail);
|
||||||
|
|||||||
@@ -1461,7 +1461,7 @@ function addDynamicListeners() {
|
|||||||
if(substr != "<i c" && !html.classList.contains("waves-effect") && !html.classList.contains("result-start") && !html.classList.contains("result-end") && !html.classList.contains("result-get-more-info")){
|
if(substr != "<i c" && !html.classList.contains("waves-effect") && !html.classList.contains("result-start") && !html.classList.contains("result-end") && !html.classList.contains("result-get-more-info")){
|
||||||
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 tags = e.getAttribute("data-video-tags").split(",");
|
var tags = e.getAttribute("data-tags").split(",");
|
||||||
var original_length = e.getAttribute("data-video-length");
|
var original_length = e.getAttribute("data-video-length");
|
||||||
var start = parseInt(e.querySelector(".result-start").value);
|
var start = parseInt(e.querySelector(".result-start").value);
|
||||||
var end = parseInt(e.querySelector(".result-end").value);
|
var end = parseInt(e.querySelector(".result-end").value);
|
||||||
@@ -1601,10 +1601,10 @@ 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 tags = e.getAttribute("data-video-tags");
|
|
||||||
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 tags = parent.parentElement.getAttribute("data-tags").split(",");
|
||||||
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) {
|
||||||
@@ -1654,13 +1654,14 @@ function addDynamicListeners() {
|
|||||||
var title = e.getAttribute("data-video-title");
|
var title = e.getAttribute("data-video-title");
|
||||||
var length = e.getAttribute("data-video-length");
|
var length = e.getAttribute("data-video-length");
|
||||||
var added_by = e.getAttribute("data-added-by");
|
var added_by = e.getAttribute("data-added-by");
|
||||||
|
var tags = e.getAttribute("data-tags");
|
||||||
var source = "youtube";
|
var source = "youtube";
|
||||||
var thumbnail;
|
var thumbnail;
|
||||||
if(e.getAttribute("data-video-source") != undefined) {
|
if(e.getAttribute("data-video-source") != undefined) {
|
||||||
source = "soundcloud";
|
source = "soundcloud";
|
||||||
thumbnail = e.getAttribute("data-type-thumbnail");
|
thumbnail = e.getAttribute("data-type-thumbnail");
|
||||||
}
|
}
|
||||||
Search.submit(id, title, parseInt(length), false, 0, 1, 0, parseInt(length), source, thumbnail);
|
Search.submit(id, title, parseInt(length), false, 0, 1, 0, parseInt(length), source, thumbnail, tags);
|
||||||
if(added_by == "user") {
|
if(added_by == "user") {
|
||||||
number_suggested = number_suggested - 1;
|
number_suggested = number_suggested - 1;
|
||||||
if(number_suggested < 0) number_suggested = 0;
|
if(number_suggested < 0) number_suggested = 0;
|
||||||
|
|||||||
@@ -108,7 +108,8 @@ 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;
|
||||||
|
var tags = "";
|
||||||
|
if(song.snippet.tags != undefined) tags = song.snippet.tags.join(",");
|
||||||
//$("#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;
|
||||||
@@ -120,7 +121,7 @@ var Search = {
|
|||||||
songs.querySelector("#add-many").setAttribute("data-video-length", secs);
|
songs.querySelector("#add-many").setAttribute("data-video-length", secs);
|
||||||
//$($(songs).querySelector("div")[0]).setAttribute("onclick", "submitAndClose('"+id+"','"+enc_title+"',"+secs+");");
|
//$($(songs).querySelector("div")[0]).setAttribute("onclick", "submitAndClose('"+id+"','"+enc_title+"',"+secs+");");
|
||||||
songs.querySelector("#temp-results").setAttribute("data-video-id", id);
|
songs.querySelector("#temp-results").setAttribute("data-video-id", id);
|
||||||
songs.querySelector("#temp-results").setAttribute("data-video-tags", song.snippet.tags.join(","));
|
songs.querySelector("#temp-results").setAttribute("data-tags", tags.toLowerCase());
|
||||||
songs.querySelector("#temp-results").setAttribute("data-video-title", enc_title);
|
songs.querySelector("#temp-results").setAttribute("data-video-title", enc_title);
|
||||||
songs.querySelector("#temp-results").setAttribute("data-video-length", secs);
|
songs.querySelector("#temp-results").setAttribute("data-video-length", secs);
|
||||||
songs.querySelector(".open-externally").setAttribute("href", "https://www.youtube.com/watch?v=" + id);
|
songs.querySelector(".open-externally").setAttribute("href", "https://www.youtube.com/watch?v=" + id);
|
||||||
@@ -247,6 +248,7 @@ var Search = {
|
|||||||
songs.querySelector("#add-many").setAttribute("data-video-title", enc_title);
|
songs.querySelector("#add-many").setAttribute("data-video-title", enc_title);
|
||||||
songs.querySelector("#add-many").setAttribute("data-video-length", secs);
|
songs.querySelector("#add-many").setAttribute("data-video-length", secs);
|
||||||
//$($(songs).querySelector("div")[0]).setAttribute("onclick", "submitAndClose('"+id+"','"+enc_title+"',"+secs+");");
|
//$($(songs).querySelector("div")[0]).setAttribute("onclick", "submitAndClose('"+id+"','"+enc_title+"',"+secs+");");
|
||||||
|
songs.querySelector("#temp-results").setAttribute("data-tags", song.genre.toLowerCase());
|
||||||
songs.querySelector("#temp-results").setAttribute("data-video-id", id);
|
songs.querySelector("#temp-results").setAttribute("data-video-id", id);
|
||||||
songs.querySelector("#temp-results").setAttribute("data-video-title", enc_title);
|
songs.querySelector("#temp-results").setAttribute("data-video-title", enc_title);
|
||||||
songs.querySelector("#temp-results").setAttribute("data-video-length", secs);
|
songs.querySelector("#temp-results").setAttribute("data-video-length", secs);
|
||||||
|
|||||||
@@ -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,tags,thumbnails))&key="+api_key.youtube+"&id=";
|
||||||
|
|
||||||
Helper.ajax({
|
Helper.ajax({
|
||||||
type: "GET",
|
type: "GET",
|
||||||
@@ -93,6 +93,7 @@ var Suggestions = {
|
|||||||
duration = Helper.secondsToOther(Search.durationToSeconds(duration));
|
duration = Helper.secondsToOther(Search.durationToSeconds(duration));
|
||||||
var video_id = song.id;
|
var video_id = song.id;
|
||||||
var video_title = song.snippet.title;
|
var video_title = song.snippet.title;
|
||||||
|
var tags = song.snippet.tags;
|
||||||
var viewCount = 0;
|
var viewCount = 0;
|
||||||
try {
|
try {
|
||||||
viewCount = song.statistics.viewCount.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
viewCount = song.statistics.viewCount.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
||||||
@@ -101,7 +102,7 @@ var Suggestions = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
document.getElementById("suggest-song-html").insertAdjacentHTML("beforeend", List.generateSong({id: video_id, title: video_title, length: length, duration: duration, votes: viewCount, extra: "Views", source: "youtube"}, false, false, false));
|
document.getElementById("suggest-song-html").insertAdjacentHTML("beforeend", List.generateSong({id: video_id, title: video_title, length: length, duration: duration, votes: viewCount, extra: "Views", source: "youtube", tags:tags}, false, false, false));
|
||||||
} catch(e) {}
|
} catch(e) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user