mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-12-07 20:18:49 +00:00
Moved SoundCloud api-key out to different config file and fixed some list-naming issues that was caused with filter.clean was performed after list-name was encoded. Closes #362
This commit is contained in:
@@ -31,8 +31,12 @@ $(document).on("click", "#refresh_all", function(e){
|
||||
function decodeChannelName(str) {
|
||||
var _fn = decodeURIComponent;
|
||||
str = str.toUpperCase();
|
||||
var toReturn = _fn(str.replace(/%5F/g, "_"));
|
||||
return toReturn.toLowerCase();
|
||||
try {
|
||||
var toReturn = _fn(str.replace(/%5F/g, "_"));
|
||||
return toReturn.toLowerCase();
|
||||
} catch(e) {
|
||||
return str.toLowerCase();
|
||||
}
|
||||
}
|
||||
|
||||
socket.on("spread_listeners", function(obj){
|
||||
|
||||
@@ -3096,6 +3096,10 @@ nav ul li:hover, nav ul li.active {
|
||||
width: 100vw;
|
||||
}
|
||||
|
||||
#search-wrapper:hover, #song-title:hover {
|
||||
background: inherit;
|
||||
}
|
||||
|
||||
#toast-container{
|
||||
left:0% !important;
|
||||
width:100vw;
|
||||
|
||||
@@ -16,10 +16,13 @@ var Channel = {
|
||||
Helper.addClass(".pagination-results", "client-pagination-height");
|
||||
Helper.addClass(".control-list", "client-control-list");
|
||||
} else {
|
||||
SC.initialize({
|
||||
client_id: 'ed53fc01f248f15becddf8eb52cc91ef'
|
||||
}, function() {
|
||||
});
|
||||
if(!api_key.hasOwnProperty("soundcloud")) soundcloud_enabled = false;
|
||||
else {
|
||||
SC.initialize({
|
||||
client_id: api_key.soundcloud
|
||||
}, function() {
|
||||
});
|
||||
}
|
||||
if(cast_ready_connect || chromecastAvailable || chromecastReady) {
|
||||
Helper.addClass(".volume-container", "volume-container-cast");
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ var paused = false;
|
||||
var client = false;
|
||||
var startTime = 0;
|
||||
var hostMode = false;
|
||||
var soundcloud_enabled = true;
|
||||
var socket_connected = false;
|
||||
var dynamicListeners = {};
|
||||
var player_ready = false;
|
||||
@@ -54,7 +55,7 @@ var Crypt = {
|
||||
};
|
||||
|
||||
SC.initialize({
|
||||
client_id: 'ed53fc01f248f15becddf8eb52cc91ef'
|
||||
client_id: api_key.soundcloud
|
||||
}, function() {
|
||||
});
|
||||
|
||||
|
||||
@@ -254,7 +254,7 @@ var List = {
|
||||
Helper.ajax({
|
||||
method: "get",
|
||||
url: 'https://www.googleapis.com/youtube/v3/videos?id=' + full_playlist[i].id
|
||||
+ "&key=" + api_key + "&part=snippet",
|
||||
+ "&key=" + api_key.youtube + "&part=snippet",
|
||||
success: function (data) {
|
||||
data = JSON.parse(data);
|
||||
//Helper.log("Empty-checker items " + data.items.length);
|
||||
@@ -813,7 +813,7 @@ var List = {
|
||||
exportToYoutube: function() {
|
||||
ga('send', 'event', "export", "youtube");
|
||||
|
||||
var request_url = "https://www.googleapis.com/youtube/v3/playlists?part=snippet&key=" + api_key;
|
||||
var request_url = "https://www.googleapis.com/youtube/v3/playlists?part=snippet&key=" + api_key.youtube;
|
||||
Helper.removeClass(".exported-list-container", "hide");
|
||||
Helper.removeClass("#playlist_loader_export", "hide");
|
||||
Helper.ajax({
|
||||
@@ -833,7 +833,7 @@ var List = {
|
||||
response = JSON.parse(response);
|
||||
var number_added = 0;
|
||||
var playlist_id = response.id;
|
||||
var request_url = "https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&key=" + api_key;
|
||||
var request_url = "https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&key=" + api_key.youtube;
|
||||
List.addToYoutubePlaylist(playlist_id, full_playlist, number_added, request_url)
|
||||
},
|
||||
error: function(response){
|
||||
@@ -902,12 +902,12 @@ var List = {
|
||||
if(full_playlist[num].hasOwnProperty("source") && full_playlist[num].source != "soundcloud") {
|
||||
List.insertInYouTubePlaylist(playlist_id, full_playlist[num].id, num, request_url)
|
||||
} else {
|
||||
var yt_url = "https://www.googleapis.com/youtube/v3/search?key="+api_key+"&videoEmbeddable=true&part=id,snippet&fields=items(id,snippet)&type=video&order=relevance&safeSearch=none&maxResults=10&videoCategoryId=10";
|
||||
var yt_url = "https://www.googleapis.com/youtube/v3/search?key="+api_key.youtube+"&videoEmbeddable=true&part=id,snippet&fields=items(id,snippet)&type=video&order=relevance&safeSearch=none&maxResults=10&videoCategoryId=10";
|
||||
yt_url+="&q="+full_playlist[num].title;
|
||||
var title = full_playlist[num].title;
|
||||
var temptitle = title.split("-");
|
||||
temptitle = temptitle.join(" ").split(" ");
|
||||
var vid_url = "https://www.googleapis.com/youtube/v3/videos?part=contentDetails,snippet,id&key="+api_key+"&id=";
|
||||
var vid_url = "https://www.googleapis.com/youtube/v3/videos?part=contentDetails,snippet,id&key="+api_key.youtube+"&id=";
|
||||
Helper.ajax({
|
||||
type: "GET",
|
||||
url: yt_url,
|
||||
|
||||
@@ -5,6 +5,7 @@ var client = false;
|
||||
if(domain.length > 0 && domain[0] == "client") {
|
||||
client = true;
|
||||
}
|
||||
var soundcloud_enabled = true;
|
||||
var local_new_channel = false;
|
||||
var hiddenPlaylist = false;
|
||||
var videoSource;
|
||||
|
||||
@@ -245,6 +245,10 @@ var Player = {
|
||||
//Playercontrols.play_pause();
|
||||
} else {
|
||||
if(videoSource == "soundcloud") {
|
||||
if(!soundcloud_enabled) {
|
||||
console.error("SoundCloud isn't enabled, so can't search on SoundCloud..");
|
||||
return;
|
||||
}
|
||||
Player.soundcloud_player.play();
|
||||
//SC.Widget(document.querySelector("#soundcloud_player")).play();
|
||||
} else {
|
||||
@@ -264,6 +268,10 @@ var Player = {
|
||||
} else {
|
||||
paused = true;
|
||||
if(videoSource == "soundcloud") {
|
||||
if(!soundcloud_enabled) {
|
||||
console.error("SoundCloud isn't enabled, so can't search on SoundCloud..");
|
||||
return;
|
||||
}
|
||||
Player.soundcloud_player.pause();
|
||||
//SC.Widget(document.querySelector("#soundcloud_player")).pause();
|
||||
} else {
|
||||
@@ -283,6 +291,10 @@ var Player = {
|
||||
},
|
||||
|
||||
loadSoundCloud: function(id, this_duration, start, end, _autoplay) {
|
||||
if(!soundcloud_enabled) {
|
||||
console.error("SoundCloud isn't enabled, so can't search on SoundCloud..");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
if(SC == null) return;
|
||||
} catch(e) {
|
||||
|
||||
@@ -44,14 +44,14 @@ var Search = {
|
||||
if(search_input !== ""){
|
||||
searching = true;
|
||||
var keyword= encodeURIComponent(search_input);
|
||||
var yt_url = "https://www.googleapis.com/youtube/v3/search?key="+api_key+"&videoEmbeddable=true&part=id&type=video&order=relevance&safeSearch=none&maxResults=25";
|
||||
var yt_url = "https://www.googleapis.com/youtube/v3/search?key="+api_key.youtube+"&videoEmbeddable=true&part=id&type=video&order=relevance&safeSearch=none&maxResults=25";
|
||||
yt_url+="&q="+keyword;
|
||||
if(music)yt_url+="&videoCategoryId=10";
|
||||
if(pagination) yt_url += "&pageToken=" + pagination;
|
||||
var vid_url = "https://www.googleapis.com/youtube/v3/videos?part=contentDetails,snippet,id&key="+api_key+"&id=";
|
||||
var vid_url = "https://www.googleapis.com/youtube/v3/videos?part=contentDetails,snippet,id&key="+api_key.youtube+"&id=";
|
||||
if(related) {
|
||||
var yt_url = "https://www.googleapis.com/youtube/v3/search?part=snippet&maxResults=25&relatedToVideoId="+keyword+"&type=video&key="+api_key;
|
||||
var vid_url = "https://www.googleapis.com/youtube/v3/videos?part=contentDetails,snippet,id&key="+api_key+"&id=";
|
||||
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=";
|
||||
}
|
||||
|
||||
Helper.addClass(document.querySelector("#search-btn .material-icons"), "hide");
|
||||
@@ -196,6 +196,11 @@ var Search = {
|
||||
},
|
||||
|
||||
soundcloudSearch: function(keyword) {
|
||||
if(!soundcloud_enabled) {
|
||||
document.querySelector("#results_soundcloud").innerHTML = '<div style="display:block;" id="inner-results" class="empty-inner-results"><div id="empty-results" class="valign-wrapper><span class="valign">No SoundCloud API-key, search disabled..</span></div></div>';
|
||||
|
||||
return;
|
||||
}
|
||||
if(keyword.length == 0) return;
|
||||
SC.get('/tracks', {
|
||||
q: keyword
|
||||
@@ -308,9 +313,9 @@ var Search = {
|
||||
|
||||
backgroundSearch: function(title, artist, length, totalNumber, current){
|
||||
var keyword= encodeURIComponent(title + " " + artist);
|
||||
var yt_url = "https://www.googleapis.com/youtube/v3/search?key="+api_key+"&videoEmbeddable=true&part=id,snippet&fields=items(id,snippet)&type=video&order=relevance&safeSearch=none&maxResults=10&videoCategoryId=10";
|
||||
var yt_url = "https://www.googleapis.com/youtube/v3/search?key="+api_key.youtube+"&videoEmbeddable=true&part=id,snippet&fields=items(id,snippet)&type=video&order=relevance&safeSearch=none&maxResults=10&videoCategoryId=10";
|
||||
yt_url+="&q="+keyword;
|
||||
var vid_url = "https://www.googleapis.com/youtube/v3/videos?part=contentDetails,snippet,id&key="+api_key+"&id=";
|
||||
var vid_url = "https://www.googleapis.com/youtube/v3/videos?part=contentDetails,snippet,id&key="+api_key.youtube+"&id=";
|
||||
artist = artist.split(" ");
|
||||
var temptitle = title.split("-");
|
||||
temptitle = temptitle.join(" ").split(" ");
|
||||
@@ -454,7 +459,7 @@ importPlaylist: function(pId,pageToken){
|
||||
var datatype;
|
||||
if(pageToken !== undefined)
|
||||
token = "&pageToken="+pageToken;
|
||||
playlist_url = "https://www.googleapis.com/youtube/v3/playlistItems?part=contentDetails&maxResults=49&key="+api_key+"&playlistId="+pId+token;
|
||||
playlist_url = "https://www.googleapis.com/youtube/v3/playlistItems?part=contentDetails&maxResults=49&key="+api_key.youtube+"&playlistId="+pId+token;
|
||||
if(youtube_authenticated) {
|
||||
datatype = "html";
|
||||
headers = {
|
||||
@@ -597,7 +602,7 @@ importSpotifyPlaylist: function(url){
|
||||
addVideos: function(ids){
|
||||
var more = false;
|
||||
var next_ids = [];
|
||||
var request_url="https://www.googleapis.com/youtube/v3/videos?part=contentDetails,snippet,id&key=" + api_key + "&id=";
|
||||
var request_url="https://www.googleapis.com/youtube/v3/videos?part=contentDetails,snippet,id&key=" + api_key.youtube + "&id=";
|
||||
for(var i = 0; i < ids.length; i++) {
|
||||
if(i > 48) {
|
||||
more = true;
|
||||
|
||||
@@ -53,8 +53,8 @@ var Suggestions = {
|
||||
Helper.removeClass(document.querySelector(".suggest-title-info"), "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;
|
||||
var video_urls = "https://www.googleapis.com/youtube/v3/videos?part=contentDetails,snippet,id&key="+api_key+"&id=";
|
||||
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&key="+api_key.youtube+"&id=";
|
||||
|
||||
Helper.ajax({
|
||||
type: "GET",
|
||||
|
||||
Reference in New Issue
Block a user