mirror of
				https://github.com/KevinMidboe/zoff.git
				synced 2025-10-29 18:00:23 +00:00 
			
		
		
		
	Added spotify playlist image on exportation
This commit is contained in:
		@@ -8,7 +8,7 @@ window.addEventListener("load", function() {
 | 
			
		||||
    if(query.spotify) {
 | 
			
		||||
        client_id = "b934ecdd173648f5bcd38738af529d58";
 | 
			
		||||
        response  = "token";
 | 
			
		||||
        scope     = "playlist-read-private playlist-read-collaborative user-read-private playlist-modify-public";
 | 
			
		||||
        scope     = "playlist-read-private ugc-image-upload playlist-read-collaborative user-read-private playlist-modify-public playlist-modify-private";
 | 
			
		||||
        state     = query.nonce;
 | 
			
		||||
        window.location.href = "https://accounts.spotify.com/authorize?client_id=" + client_id + "&scope=" + scope + "&show_dialog=false&response_type=" + response + "&redirect_uri=" + redirect + "&state=" + state;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -575,11 +575,35 @@ var List = {
 | 
			
		||||
                    },
 | 
			
		||||
                    data: JSON.stringify({
 | 
			
		||||
                        name: chan.toLowerCase() + " - Zoff",
 | 
			
		||||
                        description: "Playlist exported from Zoff (https://zoff.me/" + chan.toLowerCase() + "/)",
 | 
			
		||||
                        public: true
 | 
			
		||||
                    }),
 | 
			
		||||
                    success: function(response){
 | 
			
		||||
                        var playlist_id = response.id;
 | 
			
		||||
                        //$.each(full_playlist, function(i, curr_song){
 | 
			
		||||
                        $.ajax({
 | 
			
		||||
                            type: "GET",
 | 
			
		||||
                            url: window.location.protocol + "//" + window.location.hostname + "/assets/images/small-square.base64.txt",
 | 
			
		||||
                            success: function(base64image) {
 | 
			
		||||
                                var image = base64image.substring(0, base64image.length - 1);
 | 
			
		||||
                                $.ajax({
 | 
			
		||||
                                    type: "PUT",
 | 
			
		||||
                                    url: "https://api.spotify.com/v1/users/" + user_id + "/playlists/" + playlist_id + "/images",
 | 
			
		||||
                                    headers: {
 | 
			
		||||
                                        'Authorization': 'Bearer ' + access_token_data.access_token,
 | 
			
		||||
                                        'Content-Type': 'image/jpeg'
 | 
			
		||||
                                    },
 | 
			
		||||
                                    contentType: "image/jpeg",
 | 
			
		||||
                                    data: image,
 | 
			
		||||
                                    success: function(resp) {
 | 
			
		||||
                                        console.log(resp);
 | 
			
		||||
                                        console.log("Added image");
 | 
			
		||||
                                    },
 | 
			
		||||
                                    error: function(error) {
 | 
			
		||||
                                        console.log(error);
 | 
			
		||||
                                    }
 | 
			
		||||
                                });
 | 
			
		||||
                            }
 | 
			
		||||
                        });
 | 
			
		||||
                        var i = 0;
 | 
			
		||||
                            List.searchSpotify(full_playlist[i], playlist_id, user_id, full_playlist, i);
 | 
			
		||||
                        //});
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user