An automatic playlist updater using Spotify API and Authorization code flow in Python to update a Playlist on a repeating time interval.
- Python 3
- A Package Management System for Python.
- Installation Link
- For Windows, you can run
py -m ensurepip --upgrade
in CMD to install.
- Python job scheduler to run the script on a timer.
- Installation Link
- For Windows, you can run
-m pip install schedule --upgrade
in CMD to install.
- No website required, only a web domain for redirecting the API request and retrieving the user authorization token.
- If you don't already own a domain, you can create one at https//wix.com
- Python library for the Spotify Web API
- Installation Link
- For Windows, you can run
py -m pip install spotipy --upgrade
in CMD to install.
- Install the dependencies listed above.
- Choose a location on your device (I'll refer to this as the working directory)
- Download the latest release of spotify-playlist-updater to the working directory.
- Save your playlist photo (if applicable) in the
data
folder of the working directory- The photo must be 150KB or less. If it is too large, resize the photo.
- You can use this website to resize your image: https://www.resizepixel.com/reduce-image-in-kb/
- Login to Spotify Developer Account
- Go to https://developer.spotify.com/dashboard/ and click Manage Dashboard.
- Then, sign in with your Spotify credentials and accept the latest Developer terms of service.
- Note your Client ID, and Client Secret.
- Create an App
- In the Developer Dashboard, create an App. You can put whatever you'd like for the App name and description.
- Click Edit Settings.
- Add your domain address to the Redirected URI's field, and click Add. Make sure to Save.
- Right click \spotify-playlist-updater.py from the working directory, and select "Edit with IDLE"
- Put your Playlist Image path in place of:
"C:\\Users\\You\\YourWorkingDirectory\\Data\\PlaylistPhoto.jpeg"
- Put your Spotify Username in place of:
'username'
- Put your Client ID in place of
'clientid'
- Put your Client Secret in place of
'clientsecret'
- Put your Web Domain Address in place of
'http://yourdomain.com'
- Put your Spotify Playlist Link in place of
'https://open.spotify.com/playlist/yourplaylist'
- Put your Playlist Description in place of
'Playlist Name'
- Put your Playlist Description in place of
'Playlist Description'
- Put your Playlist Image path in place of:
- Save the script once your changes are made.
- Right click spotify-playlist-updater.py and Open.
- The script updates the Playlist every 5 minutes. You can adjust the update frequency by changing the number value for
schedule.every(5).minutes.do(func)
- The script will restart if it runs into a timeout to prevent it from failing during an internet hiccup.
- If you have an unstable internet connection and run into issues, try removing the
continue
statement.
- If you have an unstable internet connection and run into issues, try removing the
If you enjoyed my project, please feel free to leave tips on my Ko-Fi. https://ko-fi.com/autumntillman or Paypal.
- How do I schedule this to run at a set time every day instead of all the time?
- replace schedule.every(1).minutes.do(func2) with schedule.every().day.at('13:56').do(sched_job)
- note that time is based on military time (24 hour clock)
- you can replace 'day' with a specific day of the week as well
- If you get an error that "Read timed out. (read timeout=5)", restart the script.
- If your script doesnt get past "Starting Playlist Updater", run the script using IDLE:
- Right click spotify-playlist-updater and click Edit with IDLE
- Click F5 to run the script
- Let the script run. Any errors will be listed as the script encounters them.
If you're having issues getting this setup, feel free to reach out to me via Discord: .aeriie
To report code issues, create a new issue on Github or reach out to me directly at [email protected]
Aeriie on GitHub
-
0.1
- Initial Release
-
0.2
- Added improved reliability for schedule function
- Cleaned up code