mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
Merge pull request #397 from zoff-music/feature/soundcloud-import
Soundcloud import now works, but not on private songs
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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%;
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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()) {
|
||||
|
||||
@@ -343,6 +343,25 @@
|
||||
</form>
|
||||
</div>
|
||||
</li>
|
||||
<li class="white-bg">
|
||||
<div class="input-field field-settings soundcloud-import-button import-buttons">
|
||||
<a class="waves-effect btn import-soundcloud" title="Import SoundCloud playlist">
|
||||
<img src="https://developers.soundcloud.com/assets/powered_by_large_white-9c2af6a93ad2b1c541f423d9e9045980.png" class="left soundcloud_logo" alt="SoundCloud Logo" />SoundCloud
|
||||
</a>
|
||||
</div>
|
||||
<div class="input-field field-settings soundcloud_authenticated hide">
|
||||
<form action="#" id="listImportSoundCloud">
|
||||
<i class="material-icons import-icon">playlist_add</i>
|
||||
<input title="Input SoundCloud-playlist url here!" placeholder="Enter SoundCloud-list url" id="import_soundcloud" type="text" class="validate" autocomplete="off" />
|
||||
<p class="soundcloud-disclaimer">Private lists won't work with imports yet, due to our API-key being limited at the time being. Sorry for any inconvinience.</p>
|
||||
</form>
|
||||
<div id="playlist_loader_soundcloud" class="valign playlist_loader_padding hide">
|
||||
<div class="preloader-wrapper small active">
|
||||
{{> spinner}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li class="white-bg">
|
||||
<div class="input-field field-settings import-buttons import-zoff-container">
|
||||
<a class="waves-effect zoff-color lighten btn import-zoff" title="Import Zoff playlist">
|
||||
|
||||
Reference in New Issue
Block a user