Atahan
Posted on February 27, 2020
Digital transformation affected our music listening habits. Before Spotify or any other online music library we used to have mp3 archieves in our hard drives. The aim of this side project is collecting mp3 filenames from harddisk and create Spotify Playlist based on selected folder. So you will be able to listen old songs that you cannot remember.
To use this application you need a Spotify Developer Account. To use the Web API, start by creating a Spotify user account (Premium or Free). To do that, simply sign up at http://www.spotify.com After creating a spotify developer account you should register an application through Dashboard.
After these 3 steps your application should be created successfully.
After creating you will have ClientID and Client Secret values. After creating app from Edit Settings tab you should set Redirection URLs.
By using https://developer.spotify.com/console/get-current-user/ link you can get your UserID of Spotify account.
To make application work ClientID, SecretID and UserID should be placed in exampleappsettings.config file.
After setting these config values application is ready to run. You can reach codes from https://github.com/atahanceylan/winamptospotifyforms
I learned Access Token based authorization .Net app by https://github.com/bmsimons/dotnet-core-spotify-authentication github repo. Many thanks to Bart Simons (https://bartsimons.me/)
Here is GUI of WinampToSpotify windows form app:
First step is getting Access Token. After getting access token select folder to process.To simulate Oauth process with callback I used webbrowser code from https://adndevblog.typepad.com/cloud_and_mobile/2016/10/3-legged-oauth-on-desktop-apps-c-winform.html post.
Access token stored in an invisible textbox.
Example folder I selected Black Eyed Peas.From selected folder path I get the Black Eyed Peas as a playlist name. For creating playlist in Spotify I made a post request to https://api.spotify.com/v1/users/{YourUserId}/playlists endpoint.
In project, SpotifyClient.GetTrackUri method created for each track name https://api.spotify.com/v1/search?q={trackname} endpoint called and Returned trackuri stored in dictionary. TrackUri is unique identifier for tracks in Spotify API.
In project SpotifyClient.AddTrackToPlaylist method created for after getting all trackuri values these tracks added to created playlist. This is done by a post call to https://api.spotify.com/v1/playlists/{playlist_id}/tracks
All codes reachable for Windows Form Winamp to Spotify porject https://github.com/atahanceylan/winamptospotifyforms
I also created Web application of Winamp to Spotify.First page is below starts with authenticating to Spotify.
After authenticating to Spotify API next page will welcome you. You should enter the path full to search mp3s.
I selected Scorpions folder. And folder processed and created playlist in Spotify.
You can reach Winamp To Spotify web application codes: https://github.com/atahanceylan/winamptospotifyweb
Any comments and suggestions are welcome.
Posted on February 27, 2020
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.