This project allows you to automatically back up your Spotify Discover Weekly playlist to an archive playlist each week. The script checks for new tracks and appends them to your archive, ensuring you never lose a track you discover.
- Python 3.x
- Spotify Developer Account (to create an app and get API credentials)
-
Clone the Repository
git clone <repository-url> cd weekly_backup
-
Create a Virtual Environment
python3 -m venv myenv source myenv/bin/activate
-
Install Dependencies
pip install -r requirements.txt
Create a config.json
file in the root directory of the project with your Spotify API credentials. You can obtain these credentials by creating a Spotify app at Spotify Developer Dashboard.
config.json
:
{
"CLIENT_ID": "your_spotify_client_id",
"CLIENT_SECRET": "your_spotify_client_secret",
"REDIRECT_URI": "http://localhost:8888/callback"
}
- CLIENT_ID: Your Spotify application's client ID.
- CLIENT_SECRET: Your Spotify application's client secret.
- REDIRECT_URI: The URI to redirect after authorization (use
http://localhost:8888/callback
for local testing).
You can automate the backup using GitHub Actions, which runs the script every week without depending on your local machine's availability.
- Go to your GitHub repository, click on Settings -> Secrets and variables -> Actions.
- Create the following repository secrets:
SPOTIFY_CLIENT_ID
: Your Spotify Client ID.SPOTIFY_CLIENT_SECRET
: Your Spotify Client Secret.SPOTIFY_REDIRECT_URI
: Set this tohttp://localhost:8888/callback
.
To run the backup script manually:
-
Activate the Virtual Environment
source myenv/bin/activate
-
Run the Script
python weekly_backup.py
This project is licensed under the MIT License.