Winamp to Spotify
Tags: winamp, spotify, webdev, dotnet
Published: 2020-02-27 08:49:06

---
title: Winamp to Spotify
published: true
description: My side project exporting old mp3 archieves to Spotify
tags: winamp,spotify,webdev,dotnet
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/ht0euy8moc577h29a78x.png
---

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](https://dev-to-uploads.s3.amazonaws.com/i/s59sahi3ztjihphtl8m3.gif)

After these 3 steps your application should be created successfully.

![Dashboard view after creating application](https://dev-to-uploads.s3.amazonaws.com/i/fqvj3ml5cc8efmem3owo.png)

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](https://dev-to-uploads.s3.amazonaws.com/i/tprrn9g23aa0dnddccd8.png)

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](https://dev-to-uploads.s3.amazonaws.com/i/rx0vwg6ol9t6zf18a6jg.png)

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

![exampleappsettings.config file.](https://dev-to-uploads.s3.amazonaws.com/i/ljpskwv7bhe8vg848403.png)

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](https://dev-to-uploads.s3.amazonaws.com/i/1c8e82m85qp8y4mhdt7d.png)

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.](https://dev-to-uploads.s3.amazonaws.com/i/1r0rhfda60nqco0l9z7s.png)

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](https://dev-to-uploads.s3.amazonaws.com/i/6zkneb9kyqxeusx0t37w.png)


![Folder view](https://dev-to-uploads.s3.amazonaws.com/i/jw7l94snl9cz54ew9kk8.png)

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](https://dev-to-uploads.s3.amazonaws.com/i/wh5342c2xkkkuh3tgyti.png)

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](https://dev-to-uploads.s3.amazonaws.com/i/iva49ul9xy84376czj9j.png)

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](https://dev-to-uploads.s3.amazonaws.com/i/wp9wtla1bujylty7o8fz.png)

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

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/xki39fwno5rctaayv6bg.png)

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/hpd8ad0qfeiq05sj1r2n.png)

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

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/6y9b2rm4o5jbplh8wh1k.png)

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/b6bc51t4mitbe28gbiyu.png)

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