What's your top 50 most listened tracks on spotify? 🎵🎧
Reference:
Invoke an API endpoint to get json data of your most listened tracks. Then visualize that in whatever BI tools for some analysis. My initial use case was just listing it out in a table. Why? It's useful for when going for a karaoke marathon where you can just queue up all the songs based on what you have in the list 🎤
- Turn the
env.txtto.envfile. - Get your virtual env and
pip installset up by run the following on your Windows(👀) cmd:-
python -m venv .venv -
.venv\Scripts\activate -
pip install -r ./env_req.txt
-
- Download chromedriver - version of your Chrome browser
- You will need to update the path in the
main.pyto wherever the habitat of thechromedriver.exeis
- You will need to update the path in the
- Create an app on your account dashboard
- This is where you will get your client id and client secret
Steps to Produce the same result in data
- Fill in
.envfile with your client id and client secret from Pre-Requisite section. - Update
executable_pathto be wherever you downloaded chromedriver from pre-req step. - Run the script in
main.py. - You will get prompted to input your username and password for spotify since the data will be from your account.
- Once the program finishes running, you should get 2 json files:
raw_artistsandraw_top_tracks - Run the script in
data_cleaning.pyand this will get youspotify.csv. - Drop the csv file into Tableau template if you wish or connect it to your own BI tool (you might need to do your own data transformation for that BI tool.) OR do whatever you wish!
Note:
splintermodule was working for me in jupyter notebook but notmain.py, so I switched to usingseleniummodule instead since it was a good learning opportunity. Comment out the code according to what module you end up using.apidirectory has all the different endpoints that I broke apart frommain.py.