diff --git a/server/handlers/list.js b/server/handlers/list.js index 6f09b0c3..b0a73be6 100644 --- a/server/handlers/list.js +++ b/server/handlers/list.js @@ -136,7 +136,7 @@ function skip(list, guid, coll, offline, socket) { } if(!list.hasOwnProperty("id") || !list.hasOwnProperty("channel") || - typeof(list.id) != "string" || typeof(list.channel) != "string") { + (typeof(list.id) != "string" && typeof(list.id) != "number") || typeof(list.channel) != "string") { var result = { channel: { expected: "string", diff --git a/server/public/assets/css/style.css b/server/public/assets/css/style.css index de87b648..6e2c321c 100755 --- a/server/public/assets/css/style.css +++ b/server/public/assets/css/style.css @@ -382,7 +382,7 @@ li.disabled span { color: white !important; } -.import-spotify-auth, .import-youtube, .export-spotify-auth, .export-youtube, .exported-playlist, .import-zoff{ +.import-spotify-auth, .import-youtube, .export-spotify-auth, .export-youtube, .exported-playlist, .import-zoff, .import-soundcloud{ color:white !important; height:40px !important; line-height: 40px !important; @@ -390,6 +390,18 @@ li.disabled span { width: 76%; } +.import-soundcloud, .import-soundcloud:active, .import-soundcloud:visited { + background: #f96200; +} + +.import-soundcloud:hover { + background: #f97f30; +} + +.soundcloud_logo { + height: 100%; +} + .import-spotify-auth{ padding-left:5px; } @@ -408,10 +420,6 @@ li.disabled span { padding:10px; } -.spotify_authenticated{ - display: none; -} - #chat-container{ overflow: hidden; } @@ -727,6 +735,10 @@ input[type=text]:focus:not([readonly]) + label, input[type=password]:focus:not([ text-align: right; } +.spotify_authenticated, .soundcloud_authenticated{ + display: none; +} + .field-settings{ margin-left: 25px !important; color: rgb(68,68,68); @@ -739,6 +751,15 @@ input[type=text]:focus:not([readonly]) + label, input[type=password]:focus:not([ align-items: center; } +.soundcloud_authenticated { + height: auto !important; +} + +.soundcloud-disclaimer { + line-height: 20px; + padding-right: 40px; +} + .not-imported-container{ display: block; height: 100% !important; @@ -765,7 +786,7 @@ input[type=text]:focus:not([readonly]) + label, input[type=password]:focus:not([ background-color: #ff9800 !important; } -#import, #import_spotify, #import_zoff{ +#import, #import_spotify, #import_zoff, #import_soundcloud{ width: 65%; padding-left: 35px; color: rgb(68,68,68); @@ -774,7 +795,7 @@ input[type=text]:focus:not([readonly]) + label, input[type=password]:focus:not([ height: 64px; } -#import_zoff { +#import_zoff, #listImportSoundCloud { width: 100%; } diff --git a/server/public/assets/js/listeners.js b/server/public/assets/js/listeners.js index bb5aa144..e1fda7bf 100755 --- a/server/public/assets/js/listeners.js +++ b/server/public/assets/js/listeners.js @@ -368,7 +368,6 @@ initializeCastApi = function() { paused = false; mobile_beginning = false; - //console.log("request here", request); //castSession.sendMessage("urn:x-cast:zoff.me", {type: "loadVideo", start: Player.np.start, end: Player.np.end, videoId: video_id, seekTo: _seekTo, channel: chan.toLowerCase(), source: videoSource, thumbnail: Player.np.thumbnail}) castSession.sendMessage("urn:x-cast:zoff.me", {type: "nextVideo", videoId: full_playlist[0].id, title: full_playlist[0].title, source: full_playlist[0].source, thumbnail: full_playlist[0].thumbnail}) loadChromecastVideo(); @@ -572,7 +571,10 @@ function addDynamicListeners() { addListener("click", ".extra-button-search", function(e){ this.preventDefault(); document.getElementById("search").value = e.getAttribute("data-text"); + document.querySelector(".song-title").click(); + Search.soundcloudSearch(e.getAttribute("data-text")); Search.search(e.getAttribute("data-text")); + document.getElementById("search").focus(); }); addListener("click", ".extra-button-delete", function(e){ @@ -796,7 +798,9 @@ function addDynamicListeners() { }); addListener("click", ".extra-add-text", function(e){ - e.select(); + try { + e.select(); + } catch(e) {} }); addListener("click", ".next_page", function(event){ @@ -992,6 +996,81 @@ function addDynamicListeners() { Helper.removeClass(".zoff_add_field", "hide"); }); + addListener("click", ".import-soundcloud", function(event) { + this.preventDefault(); + Helper.addClass(".soundcloud-import-button", "hide"); + Helper.removeClass(".soundcloud_authenticated", "hide"); + document.querySelector("#import_soundcloud").focus(); + }); + + addListener("submit", "#listImportSoundCloud", function(event) { + this.preventDefault(); + Helper.removeClass(".playlist_loader_soundcloud", "hide"); + Helper.addClass("#listImportSoundCloud", "hide"); + Helper.ajax({ + type: "POST", + headers: { + "Content-Type": "application/json" + }, + url: "http://api.soundcloud.com/resolve/?url=" + document.querySelector("#import_soundcloud").value + "&limit=1&client_id=" + api_key.soundcloud + "&format=json&_status_code_map[200]=200", + success: function(data){ + try { + var jsonData = JSON.parse(data); + var tracks = jsonData.tracks; + document.querySelector("#import_soundcloud").value = ""; + var addList = []; + for(var i = 0; i < tracks.length; i++) { + var song = tracks[i]; + var title=song.title; + if(title.indexOf(song.user.username) == -1) { + title = song.user.username + " - " + title; + } + if(!song.streamable) { + var not_added_song = document.createElement("div"); + not_added_song.innerHTML = not_import_html; + + not_added_song.querySelector(".extra-add-text").innerText = title; + not_added_song.querySelector(".extra-add-text").setAttribute("title", title); + not_added_song.querySelector(".extra-button-search").setAttribute("data-text", title); + document.querySelector(".not-imported-container").insertAdjacentHTML("beforeend", not_added_song.innerHTML); + Helper.removeClass(".not-imported", "hide"); + continue; + } + var duration=Math.floor(song.duration / 1000); + //var secs=Search.durationToSeconds(duration); + var secs = duration; + if(longsongs == undefined) longsongs = true; + if((longsongs != undefined && !longsongs) || secs<720){ + + var id=song.id; + //duration = duration.replace("PT","").replace("H","h ").replace("M","m ").replace("S","s"); + var thumb=song.artwork_url; + //var thumb = null; + if(thumb == null) thumb = song.waveform_url; + + var songElement = {id: song.id, title: title, duration: secs, source: "soundcloud", thumbnail: thumb}; + + addList.push(songElement); + } + } + if(addList.length > 0) { + socket.emit("addPlaylist", {channel: chan.toLowerCase(), songs: addList}); + } + Helper.addClass(".playlist_loader_soundcloud", "hide"); + Helper.removeClass("#listImportSoundCloud", "hide"); + //{id: song.id, title: enc_title, duration: duration, source: "youtube", thumbnail: "https://img.youtube.com/vi/" + song.id + "/mqdefault.jpg"} + } catch(e) { + console.error(e); + Helper.addClass(".playlist_loader_soundcloud", "hide"); + Helper.removeClass("#listImportSoundCloud", "hide"); + } + }, + error: function(data) { + console.log(data); + } + }); + }); + addListener("submit", "#listImportSpotify", function(event){ this.preventDefault(); if(spotify_authenticated && document.getElementById("import_spotify").value !== ""){ @@ -1580,7 +1659,8 @@ function addDynamicListeners() { document.querySelector("#remote_channel") != document.activeElement && document.querySelector("#import") != document.activeElement && document.querySelector("#find_input") != document.activeElement && - document.querySelector("#import_spotify") != document.activeElement) { + document.querySelector("#import_spotify") != document.activeElement && + document.querySelector("#import_soundcloud") != document.activeElement) { if(chromecastAvailable) { event.preventDefault(); Player.playPauseVideo(); diff --git a/server/public/assets/js/player.js b/server/public/assets/js/player.js index c0f3e2ad..77518c20 100755 --- a/server/public/assets/js/player.js +++ b/server/public/assets/js/player.js @@ -655,7 +655,11 @@ var Player = { try { scPlaying = Player.soundcloud_player.isPlaying(); } catch(e){} - resizePlaylistPlaying(Player.player.getPlayerState() == YT.PlayerState.PLAYING || scPlaying || Player.player.getPlayerState() == YT.PlayerState.BUFFERING); + try { + resizePlaylistPlaying(Player.player.getPlayerState() == YT.PlayerState.PLAYING || scPlaying || Player.player.getPlayerState() == YT.PlayerState.BUFFERING); + } catch(e) { + resizePlaylistPlaying(scPlaying); + } } if(!chromecastAvailable){ if(Helper.mobilecheck()) { diff --git a/server/public/partials/channel/panel.handlebars b/server/public/partials/channel/panel.handlebars index d85abf0c..f1ff09ed 100755 --- a/server/public/partials/channel/panel.handlebars +++ b/server/public/partials/channel/panel.handlebars @@ -343,6 +343,25 @@ +