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.txt
to.env
file. - Get your virtual env and
pip install
set 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.py
to wherever the habitat of thechromedriver.exe
is
- 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
.env
file with your client id and client secret from Pre-Requisite section. - Update
executable_path
to 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_artists
andraw_top_tracks
- Run the script in
data_cleaning.py
and 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:
splinter
module was working for me in jupyter notebook but notmain.py
, so I switched to usingselenium
module instead since it was a good learning opportunity. Comment out the code according to what module you end up using.api
directory has all the different endpoints that I broke apart frommain.py
.