* An example of running the program.
* The web server after authenticating. This only needs to be done once (per user).
To use SpotifyRandomizer, you need spotipy.
You can install it using pip
: pip3 install spotipy
-
Create a spotify application so you can use
spotipy
. You can do this at the Spotify developer website. -
Now you need to give the program your client ID & client secret. You can do this in 2 ways:
-
Uncomment the lines in
randomizer.py
(by removing the # in the beginning of the line) that set these variables and inputting yours.os.environ["SPOTIPY_CLIENT_ID"] = "myclientid" os.environ["SPOTIPY_CLIENT_SECRET"] = "myclientsecret"
-
Export those variables using your terminal. On windows:
SET SPOTIPY_CLIENT_ID=myclientid SET SPOTIPY_CLIENT_SECRET=myclientsecret
On linux:
export SPOTIPY_CLIENT_ID=myclientid export SPOTIPY_CLIENT_SECRET=myclientsecret
You only need to do this once.
The default redirect URL is
http://localhost:14523
for the local webserver. -
-
Optionally, you can give the program the Spotify username and the playlists to shuffle. You can do this in 2 ways:
-
Uncomment the lines in
randomizer.py
(by removing the # in the beginning of the line) that set these variables and inputting yours.os.environ["USER"] = "myusername" os.environ["PLAYLISTS"] = "Playlist1,Playlist2,Playlist3"
-
Export those variables using your terminal. On windows:
SET USER=myusername SET PLAYLISTS=Playlist1,Playlist2,Playlist3
On linux:
export USER=myusername export PLAYLISTS=Playlist1,Playlist2,Playlist3
You only need to do this once.
-
-
You're done - you can basically change anything else you'd like.
The script can be ran by doing python3 main.py
.
In this case the program will ask you for your username and playlist(s) while running.
You can also give that information as an argument, like this python3 main.py 1234567890 Playlist1 Playlist2 Playlist3
The playlists can be the name of the playlist or the ID of the playlist (found in the URL). These playlists have to be owned by you.
When you run the program for the first time, it will open the spotify website for authorization. Then you need to copy the redirected URL into the commandline. After this, the program should work.
Also check out the repo SpotifyNoDupes if you want to get rid of your duplicate songs in playlists.