Automating extraction of metadata from mp3 files in a desired file directory, finding the songs on Spotify and adding all the songs into a Spotify playlist of choice.
For this project, you will need Python installed on your system.
- Spotify Web API OAuth Token.
- Spotify Playlist ID.
- Path to directory.
- Install the dependencies.
pip install -r requirements.txt
- Collect your Spotify User ID, Playlist URI and Oauth Token From Spotify and add it to the run.bat file, and also add the directory of the folder with the MP3s.
- To get your Spotify User ID, visit Spotify Account Overview:
- To get your Playlist ID, copy Spotify URI as in the screenshot: The Spotify URI will be in the format: spotify:playlist:2MplKvHDhfgoo9zngH7T2z, the playlist_id that you'll need is the last alphanum part: 2MplKvHDhfgoo9zngH7T2z.
- To get your Oauth Token, visit this page: Get Oauth and click the Get Token button:
- Run the run.bat file in your terminal:
run.bat
- Spotify Oauth token expires ver quickly (in an hour), so if you come across a
KeyError
this could be caused by an expired token. So just refer back to step 2 in local setup, and generate a new token. - The accurate metadata needs to exist in the MP3 file. If the artist name or track name is not present, it will not be added.
I tested the code on my Spotify Account (ajuanijustus), in this playlist.