A script/ local module to get the song that is next in a user's current queue.
Created for a friend to use for a twitch bot or something.
To be released under an MIT license, use this however you want, I mainly did this for a bit of fun.
(Written and tested on Python 3.11, anything above 3.9 should do though)
I would recommend setting up a virtual environment to avoid dependency contamination, although this is optional:
# Linux w/ bash shell:
python3 -m venv venv && source venv/bin/activate
# Windows 10 w/ powershell:
python3 -m venv venv
Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process -Force
./venv/Scripts/activate.ps1
Install requirements using pip:
pip install -r requirements.txt
# Or like this:
python3 -m pip install -r requirements.txt
Next in Queue & Crawl Recommeded Tracks
First, and this is very important to actually be granted access to Spotify's
API; create an application at the
Spotify dev dashboard
once done, edit it and set it's redirect URL to http://127.0.0.1:9090
and
then save the changes. Once you have done that, copy the client ID & client
secret into the redacted slots in the main.py file.
These steps are crucial.
If done correct, a brief popup will open in your default browser to grab the required token code to access your account info that is needed (in this case, it just needs your currently playing information) and the rest should just work, your next in queue will be pretty printed.
Once that is done simply do the following:
python3 main.py # Once all prerequisites are met.
There is a sub-script in this project called crawl.py
. It will take an
initial track ID and the user's playlist ID on their account that they want
to append tracks to and add tracks to it randomized, suggested by Spotify
that are similar to the original track (track ID).
Just update your details like the next in track script and run it the same.
The local module src.client
contains stuff for you to get next in queue
information if you just want the raw data.
Enjoy! ~