DEV Community

Cover image for Winamp to Spotify
Atahan
Atahan

Posted on

Winamp to Spotify

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.

Creating Application on Spotify API

After these 3 steps your application should be created successfully.

Dashboard view after creating application

After creating you will have ClientID and Client Secret values. After creating app from Edit Settings tab you should set Redirection URLs.

Redirection URLs and other settings

By using https://developer.spotify.com/console/get-current-user/ link you can get your UserID of Spotify account.

Getting UserId by calling Spotify API

To make application work ClientID, SecretID and UserID should be placed in exampleappsettings.config file.

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:

Winamp To Spotify Windows 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.

After get token finished successfully.

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.

Selecting mp3 folder

Folder view

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.

Output of application

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

Spotify Output

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.

Alt Text

After authenticating to Spotify API next page will welcome you. You should enter the path full to search mp3s.

Alt Text

Alt Text

I selected Scorpions folder. And folder processed and created playlist in Spotify.

Alt Text

Alt Text

You can reach Winamp To Spotify web application codes: https://github.com/atahanceylan/winamptospotifyweb
Any comments and suggestions are welcome.

Top comments (2)

Collapse
 
jonrandy profile image
Jon Randy ๐ŸŽ–๏ธ

I'll never use Spotify. I don't get it - why would I pay to listen to music I already own when there are other services online where I can do this 100% free

Collapse
 
atahanceylan profile image
Atahan

Fair point. I was thinking the same. But sometimes you want to listen better quality of song. And best thing for Spotify you can discover new songs and reach public playlists.