mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
Exporting to soundcloud tests
This commit is contained in:
@@ -54,7 +54,9 @@ window.addEventListener("load", function() {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
window.opener.callback(query_parameters);
|
window.opener.callback(query_parameters);
|
||||||
} catch(e) {}
|
} catch(e) {
|
||||||
|
window.setTimeout(window.opener.SC.connectCallback, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ var List = {
|
|||||||
uris: [],
|
uris: [],
|
||||||
not_found: [],
|
not_found: [],
|
||||||
num_songs: 0,
|
num_songs: 0,
|
||||||
|
found: [],
|
||||||
|
|
||||||
channel_function: function(msg) {
|
channel_function: function(msg) {
|
||||||
if(user_auth_started) {
|
if(user_auth_started) {
|
||||||
@@ -605,6 +606,68 @@ var List = {
|
|||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
exportToSoundCloud: function(thisSong, i) {
|
||||||
|
if(thisSong == undefined) {
|
||||||
|
if(full_playlist.length > 0) {
|
||||||
|
List.exportToSoundCloud(full_playlist[0], 1);
|
||||||
|
}
|
||||||
|
} else if(i != undefined && i == full_playlist.length) {
|
||||||
|
SC_player.post('/playlists', {
|
||||||
|
playlist: {
|
||||||
|
title: decodeURIComponent(channel.toLowerCase()) + ' - Zoff',
|
||||||
|
tracks: List.found,
|
||||||
|
sharing: "public"
|
||||||
|
}
|
||||||
|
}).then(function(result) {
|
||||||
|
console.log(result, List.found, List.not_found);
|
||||||
|
List.found = [];
|
||||||
|
List.not_found = [];
|
||||||
|
});
|
||||||
|
} else if(thisSong != undefined && i != undefined) {
|
||||||
|
var isFound = false;
|
||||||
|
if(thisSong.source == "soundcloud") {
|
||||||
|
List.found.push({id: thisSong.id});
|
||||||
|
List.exportToSoundCloud(full_playlist[i+1], i+1);
|
||||||
|
} else {
|
||||||
|
thisSong.title = Helper.replaceForFind(thisSong.title);
|
||||||
|
SC_player.get('/tracks', {
|
||||||
|
q: thisSong.title
|
||||||
|
}).then(function(tracks) {
|
||||||
|
//$("#results").append(result_html);
|
||||||
|
//Helper.css(document.querySelector(".search_results .col.s12"), "display", "block");
|
||||||
|
for(var y = 0; y < tracks.length; y++) {
|
||||||
|
var song = tracks[y];
|
||||||
|
if(!song.streamable) 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 title=song.title;
|
||||||
|
if(title.indexOf(song.user.username) == -1) {
|
||||||
|
title = song.user.username + " - " + title;
|
||||||
|
}
|
||||||
|
var id=song.id;
|
||||||
|
if(similarity(title, thisSong.track) > 0.60) {
|
||||||
|
List.found.push({id: song.id});
|
||||||
|
isFound = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!isFound) {
|
||||||
|
List.not_found.push(full_playlist[i].title);
|
||||||
|
}
|
||||||
|
List.exportToSoundCloud(full_playlist[i+1], i+1);
|
||||||
|
}).catch(function(e) {
|
||||||
|
List.not_found.push(full_playlist[i].title);
|
||||||
|
List.exportToSoundCloud(full_playlist[i+1], i+1);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
exportToSpotify: function() {
|
exportToSpotify: function() {
|
||||||
ga('send', 'event', "export", "spotify");
|
ga('send', 'event', "export", "spotify");
|
||||||
|
|
||||||
|
|||||||
@@ -954,7 +954,7 @@ function addDynamicListeners() {
|
|||||||
|
|
||||||
addListener("click", ".export-soundcloud", function(event) {
|
addListener("click", ".export-soundcloud", function(event) {
|
||||||
this.preventDefault();
|
this.preventDefault();
|
||||||
var nonce = Helper.randomString(29);
|
/*var nonce = Helper.randomString(29);
|
||||||
Helper.removeClass("#playlist_loader_export", "hide");
|
Helper.removeClass("#playlist_loader_export", "hide");
|
||||||
Helper.addClass(".soundcloud_export_button", "hide");
|
Helper.addClass(".soundcloud_export_button", "hide");
|
||||||
window.callback = function(data) {
|
window.callback = function(data) {
|
||||||
@@ -972,8 +972,12 @@ function addDynamicListeners() {
|
|||||||
soundcloud_window.close();
|
soundcloud_window.close();
|
||||||
window.callback = "";
|
window.callback = "";
|
||||||
};
|
};
|
||||||
soundcloud_window = window.open("/api/oauth#soundcloud=true&nonce=" + nonce, "", "width=600, height=600");
|
soundcloud_window = window.open("/api/oauth#soundcloud=true&nonce=" + nonce, "", "width=600, height=600");*/
|
||||||
})
|
|
||||||
|
SC_player.connect({"display":"page"}).then(function() {
|
||||||
|
List.exportToSoundCloud();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
addListener("click", ".export-spotify-auth", function(event){
|
addListener("click", ".export-spotify-auth", function(event){
|
||||||
this.preventDefault();
|
this.preventDefault();
|
||||||
|
|||||||
@@ -1148,7 +1148,8 @@ var Player = {
|
|||||||
try {
|
try {
|
||||||
if(SC_player != null && SC_player != undefined && SC_widget != null && SC_widget != undefined && !sc_initialized) {
|
if(SC_player != null && SC_player != undefined && SC_widget != null && SC_widget != undefined && !sc_initialized) {
|
||||||
SC_player.initialize({
|
SC_player.initialize({
|
||||||
client_id: api_key.soundcloud
|
client_id: api_key.soundcloud,
|
||||||
|
redirect_uri: "https://zoff.me/api/oauth",
|
||||||
});
|
});
|
||||||
sc_initialized = true;
|
sc_initialized = true;
|
||||||
Player.soundcloudReady();
|
Player.soundcloudReady();
|
||||||
@@ -1170,7 +1171,8 @@ var Player = {
|
|||||||
SC_player = SC;
|
SC_player = SC;
|
||||||
if(SC_player != null && SC_player != undefined && SC_widget != null && SC_widget != undefined && !sc_initialized) {
|
if(SC_player != null && SC_player != undefined && SC_widget != null && SC_widget != undefined && !sc_initialized) {
|
||||||
SC_player.initialize({
|
SC_player.initialize({
|
||||||
client_id: api_key.soundcloud
|
client_id: api_key.soundcloud,
|
||||||
|
redirect_uri: "https://zoff.me/api/oauth",
|
||||||
});
|
});
|
||||||
sc_initialized = true;
|
sc_initialized = true;
|
||||||
Player.soundcloudReady();
|
Player.soundcloudReady();
|
||||||
@@ -1183,7 +1185,8 @@ var Player = {
|
|||||||
SC_player = SC;
|
SC_player = SC;
|
||||||
if(SC_player != null && SC_player != undefined && SC_widget != null && SC_widget != undefined && !sc_initialized) {
|
if(SC_player != null && SC_player != undefined && SC_widget != null && SC_widget != undefined && !sc_initialized) {
|
||||||
SC_player.initialize({
|
SC_player.initialize({
|
||||||
client_id: api_key.soundcloud
|
client_id: api_key.soundcloud,
|
||||||
|
redirect_uri: "https://zoff.me/api/oauth",
|
||||||
});
|
});
|
||||||
sc_initialized = true;
|
sc_initialized = true;
|
||||||
Player.soundcloudReady();
|
Player.soundcloudReady();
|
||||||
@@ -1202,7 +1205,8 @@ var Player = {
|
|||||||
try {
|
try {
|
||||||
if(SC_player != null && SC_player != undefined && SC_widget != null && SC_widget != undefined && !sc_initialized) {
|
if(SC_player != null && SC_player != undefined && SC_widget != null && SC_widget != undefined && !sc_initialized) {
|
||||||
SC_player.initialize({
|
SC_player.initialize({
|
||||||
client_id: api_key.soundcloud
|
client_id: api_key.soundcloud,
|
||||||
|
redirect_uri: "https://zoff.me/api/oauth",
|
||||||
});
|
});
|
||||||
sc_initialized = true;
|
sc_initialized = true;
|
||||||
Player.soundcloudReady();
|
Player.soundcloudReady();
|
||||||
@@ -1222,7 +1226,8 @@ var Player = {
|
|||||||
SC_widget = SC;
|
SC_widget = SC;
|
||||||
if(SC_player != null && SC_player != undefined && SC_widget != null && SC_widget != undefined && !sc_initialized) {
|
if(SC_player != null && SC_player != undefined && SC_widget != null && SC_widget != undefined && !sc_initialized) {
|
||||||
SC_player.initialize({
|
SC_player.initialize({
|
||||||
client_id: api_key.soundcloud
|
client_id: api_key.soundcloud,
|
||||||
|
redirect_uri: "https://zoff.me/api/oauth",
|
||||||
});
|
});
|
||||||
sc_initialized = true;
|
sc_initialized = true;
|
||||||
Player.soundcloudReady();
|
Player.soundcloudReady();
|
||||||
@@ -1234,7 +1239,8 @@ var Player = {
|
|||||||
SC_widget = SC;
|
SC_widget = SC;
|
||||||
if(SC_player != null && SC_player != undefined && SC_widget != null && SC_widget != undefined && !sc_initialized) {
|
if(SC_player != null && SC_player != undefined && SC_widget != null && SC_widget != undefined && !sc_initialized) {
|
||||||
SC_player.initialize({
|
SC_player.initialize({
|
||||||
client_id: api_key.soundcloud
|
client_id: api_key.soundcloud,
|
||||||
|
redirect_uri: "https://zoff.me/api/oauth",
|
||||||
});
|
});
|
||||||
sc_initialized = true;
|
sc_initialized = true;
|
||||||
Player.soundcloudReady();
|
Player.soundcloudReady();
|
||||||
|
|||||||
@@ -267,8 +267,10 @@
|
|||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
<li class="white-bg">
|
<li class="white-bg">
|
||||||
<div class="input-field field-settings">
|
<div class="input-field field-settings soundcloud-export-button export-buttons">
|
||||||
<p class="soundcloud-disclaimer">Exporting to SoundCloud is in the works.</p>
|
<a class="waves-effect btn export-soundcloud" title="Export to SoundCloud">
|
||||||
|
<img src="https://developers.soundcloud.com/assets/powered_by_large_white-9c2af6a93ad2b1c541f423d9e9045980.png" class="left soundcloud_logo" alt="SoundCloud Logo" />SoundCloud
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
<li class="exported-list-container white-bg hide">
|
<li class="exported-list-container white-bg hide">
|
||||||
|
|||||||
Reference in New Issue
Block a user