mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
Improved exporting to spotify
This commit is contained in:
4
public/dist/embed.min.js
vendored
4
public/dist/embed.min.js
vendored
File diff suppressed because one or more lines are too long
6
public/dist/main.min.js
vendored
6
public/dist/main.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -492,9 +492,25 @@ var List = {
|
|||||||
'Authorization': 'Bearer ' + access_token_data.access_token
|
'Authorization': 'Bearer ' + access_token_data.access_token
|
||||||
},
|
},
|
||||||
async: true,
|
async: true,
|
||||||
|
statusCode: {
|
||||||
|
429: function(jqXHR) {
|
||||||
|
console.log(jqXHR.getAllResponseHeaders());
|
||||||
|
var retryAfter = jqXHR.getResponseHeader("Retry-After");
|
||||||
|
console.log(retryAfter);
|
||||||
|
if (!retryAfter) retryAfter = 5;
|
||||||
|
retryAfter = parseInt(retryAfter, 10);
|
||||||
|
Helper.log("Retry-After", retryAfter);
|
||||||
|
setTimeout(function(){
|
||||||
|
List.searchSpotify(curr_song);
|
||||||
|
}, retryAfter * 1000);
|
||||||
|
}
|
||||||
|
},
|
||||||
error: function(err){
|
error: function(err){
|
||||||
if(err.status == 429){
|
if(err.status == 429){
|
||||||
|
console.log(err.getAllResponseHeaders());
|
||||||
var retryAfter = err.getResponseHeader("Retry-After");
|
var retryAfter = err.getResponseHeader("Retry-After");
|
||||||
|
console.log(retryAfter);
|
||||||
|
if (!retryAfter) retryAfter = 5;
|
||||||
retryAfter = parseInt(retryAfter, 10);
|
retryAfter = parseInt(retryAfter, 10);
|
||||||
Helper.log("Retry-After", retryAfter);
|
Helper.log("Retry-After", retryAfter);
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
@@ -522,6 +538,7 @@ var List = {
|
|||||||
data.name = data.name.replace("feat", " ");
|
data.name = data.name.replace("feat", " ");
|
||||||
data.name = data.name.replace("ft.", " ");
|
data.name = data.name.replace("ft.", " ");
|
||||||
data.name = data.name.replace("radio edit", " ");
|
data.name = data.name.replace("radio edit", " ");
|
||||||
|
data.name = data.name.replace("video", " ");
|
||||||
data.name = data.name.replace("pop version", " ");
|
data.name = data.name.replace("pop version", " ");
|
||||||
data.name = data.name.replace(" ", " ").replace(" ", " ").replace(" ", " ").replace(" ", " ").replace(" ", " ").replace(" ", " ").replace(" ", " ").replace(" ", " ");
|
data.name = data.name.replace(" ", " ").replace(" ", " ").replace(" ", " ").replace(" ", " ").replace(" ", " ").replace(" ", " ").replace(" ", " ").replace(" ", " ");
|
||||||
data.artists[0].name = data.artists[0].name.replace(" ", " ").replace(" ", " ").replace(" ", " ").replace(" ", " ").replace(" ", " ").replace(" ", " ").replace(" ", " ").replace(" ", " ");
|
data.artists[0].name = data.artists[0].name.replace(" ", " ").replace(" ", " ").replace(" ", " ").replace(" ", " ").replace(" ", " ").replace(" ", " ").replace(" ", " ").replace(" ", " ");
|
||||||
@@ -560,12 +577,8 @@ var List = {
|
|||||||
if(List.uris.length > 100){
|
if(List.uris.length > 100){
|
||||||
while(List.uris.length > 100){
|
while(List.uris.length > 100){
|
||||||
List.addToSpotifyPlaylist(List.uris.slice(0, 100), playlist_id, user_id);
|
List.addToSpotifyPlaylist(List.uris.slice(0, 100), playlist_id, user_id);
|
||||||
if(List.uris.length > 200){
|
|
||||||
List.uris = List.uris.slice(100, 200);
|
|
||||||
} else {
|
|
||||||
List.uris = List.uris.slice(100, List.uris.length);
|
List.uris = List.uris.slice(100, List.uris.length);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
List.addToSpotifyPlaylist(List.uris, playlist_id, user_id);
|
List.addToSpotifyPlaylist(List.uris, playlist_id, user_id);
|
||||||
$("#playlist_loader_export").addClass("hide");
|
$("#playlist_loader_export").addClass("hide");
|
||||||
} else {
|
} else {
|
||||||
@@ -580,6 +593,7 @@ var List = {
|
|||||||
$(".not-exported-container").append(not_added_song.html());
|
$(".not-exported-container").append(not_added_song.html());
|
||||||
})
|
})
|
||||||
$(".not-exported").removeClass("hide");
|
$(".not-exported").removeClass("hide");
|
||||||
|
$(".spotify_export_button").css("display", "block");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -596,6 +610,11 @@ var List = {
|
|||||||
data: JSON.stringify({
|
data: JSON.stringify({
|
||||||
uris: uris
|
uris: uris
|
||||||
}),
|
}),
|
||||||
|
error: function(response){
|
||||||
|
setTimeout(function(){
|
||||||
|
List.addToSpotifyPlaylist(uris, playlist_id, user_id);
|
||||||
|
}, 3000);
|
||||||
|
},
|
||||||
success: function(response){
|
success: function(response){
|
||||||
Helper.log("Added songs");
|
Helper.log("Added songs");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -715,6 +715,7 @@ $(document).on("click", ".export-spotify-auth", function(e){
|
|||||||
access_token_data = {};
|
access_token_data = {};
|
||||||
spotify_is_authenticated(false);
|
spotify_is_authenticated(false);
|
||||||
}, access_token_data.expires_in * 1000);
|
}, access_token_data.expires_in * 1000);
|
||||||
|
$(".spotify_export_button").css("display", "none");
|
||||||
List.exportToSpotify();
|
List.exportToSpotify();
|
||||||
} else {
|
} else {
|
||||||
access_token_data = {};
|
access_token_data = {};
|
||||||
|
|||||||
@@ -302,7 +302,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
<li class="white-bg">
|
<li class="white-bg">
|
||||||
<div class="input-field field-settings spotify_unauthenticated export-buttons">
|
<div class="input-field field-settings spotify_export_button export-buttons">
|
||||||
<a class="modal-trigger waves-effect green lighten btn export-spotify-auth" title="Export Spotify playlist">
|
<a class="modal-trigger waves-effect green lighten btn export-spotify-auth" title="Export Spotify playlist">
|
||||||
<img src="/public/images/spotify.png" class="left spotify_logo" alt="Spotify Logo" />Spotify
|
<img src="/public/images/spotify.png" class="left spotify_logo" alt="Spotify Logo" />Spotify
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
Reference in New Issue
Block a user