Automatically update your Spotify playlists with tracks of your favorite artists and genres using this Python script powered by the Spotify Web API and GitHub Actions.
Update My Spotify Playlist is a Python tool that streamlines your Spotify playlist management by adding your favourite tracks from your favorite artists to your playlist in real-time.
- Fork this repo
- Clone your repo in local
- copy
.env-template
into.env
- Install all Python requirements in
requirements.txt
- Go to the Spotify Developer Dashboard and log in with your Spotify account.
- Click on the "Create an App" button and fill out the necessary information, such as the name and description of your application. Use
http://localhost:5000
as redirect URL - Once you've created the app, you'll be taken to the app dashboard. Here, you'll find your client ID, client secret and Redirect URL. Copy this and paste it your
.env
file - Create new playlist in your Spotify Account and copy the playlist id from the url. Paste the playlist id in
.env
file. - Run this Script
get_refresh_token.py
to get refresh token. Follow the instruction in this script. Copy the refresh token into.env
file. - Run this Script
update.py
for testing. - Add all env variable
CLIENT_ID
,CLIENT_SECRET
,REDIRECT_URI
,REFRESH_TOKEN
in github repository secret. Checkout this link to add a new repository secret. - By default it updates daily at
2:47 UTC
. You can also change this by changing the cron in/.github/workflows/main.yml
by using Cron Generator.
Your playlists can be customized by various category.
In config.py
, you can cusomize your playlists.
id
is id of your playlist and
category
is tracks of this playlist are under this category
Currenly five catgories are available
TopArtist()
TopTracks()
TopMix()
- It mix both TopArtist and TopTracksRecentlyPlayed()
Mix()
If you need a playlist with particualar artists, tracks or genre, you can use Mix()
In Mix you can mix upto 5 parameter like Artist, Genre and Track. Only 5 parameter are allowed
PLAYLISTS = [
{
'id': 'xxxxxxxxx'
'category': Mix(
[
Artist("7jVv8c5Fj3E9VhNjxT4snq"),
Artist("6M2wZ9GZgrQXHCFfjv46we"),
Artist("1Xyo4u8uXC1ZmMpatF05PJ"),
Genre("pop"),
Track("0HqZX76SFLDz2aW8aiqi7G")
]
)
}
]
sample config file, you can have multiple playlists
PLAYLISTS = [
{
'id': '2bx19B2bwgTf20XWQBxlQo',
'category': TopMix(time_range=TimeRange.long_term, no_of_tracks_required=30)
},
{
'id': '2bx19B2bwgTff20XWQBxlQo',
'category': TopArtist(time_range=TimeRange.short_term, no_of_tracks_required=30)
},
{
'id': '7sLWB2thlLWFcvuExsc77y',
'category': Mix(
[
Artist('7dGJo4pcD2V6oG8kP0tJRR'),
Artist('1mYsTxnqsietFxj1OgoGbG'),
Genre('pop')
],
no_of_tracks_required=20
)
},
{
'id': '23ljfjfwfpwjwjfwjfjfjs',
'category': RecentlyPlayed(no_of_tracks_required=23)
}
]
Contributions are Welcome. Feel free to report bugs in issue and fix some bugs by creating pull requests. Comments, Suggestions, Improvements and Enhancements are always welcome.
Distributed under the MIT license.
If you have any questions or feedback about this project, feel free to get in touch with me via mail
Thank you;
Made with Music ❤️