Automatically add newly saved songs to a monthly playlist using Spotify's Web API.
To get started, first create an app on https://developers.spotify.com/. Be sure to set a Redirect URI in app's settings.
Install spotipy using pip.
pip install spotipy
or using
pip install -r requirements.txt
from monthlyplaylists import MonthlyPlaylists
spotify = MonthlyPlaylists(
client_id='YOUR_CLIENT_ID',
client_secret='YOUR_CLIENT_SECRET',
redirect_uri='http://localhost:8888/callback'
)
spotify.update_monthly_playlists()
Calling update_monthly_playlists() checks for liked songs after a certain date and adds them to a playlist corresponding to the date the song was liked.
By default, only songs liked after the first of the month are added, and playlists are named using the current month's abbreviation and last 2 digits of the current year (ex: Jan 22).
from monthlyplaylists import MonthlyPlaylists
from datetime import datetime, timedelta
one_yr_ago = datetime.now() - timedelta(days=365)
spotify = MonthlyPlaylists(
client_id='YOUR_CLIENT_ID',
client_secret='YOUR_CLIENT_SECRET',
redirect_uri='http://localhost:8888/callback',
date=one_yr_ago,
name_format="%B '%y"
)
spotify.update_monthly_playlists()
This example will add every liked song from the last year into a monthly playlist using a different naming format (ex: January '22).