Spotify & YouTube Automation: Local Deployment Guide
Local Environment Setup
To get the automation running on your machine, follow these steps to ensure the environment is isolated and doesn't clash with your system Python.
1. Install Python 3.10+
Ensure you have a recent version of Python installed. Check your version using:
python --version2. Initialize the Project Workspace
Create a dedicated directory to keep your credentials and scripts organized.
mkdir spotify-yt-sync
cd spotify-yt-sync3. Create a Virtual Environment
I highly recommend using a venv. It prevents library version conflicts and makes the deployment process cleaner.
python -m venv venv
# On Windows:
.\venv\Scripts\activate
# On macOS/Linux:
source venv/bin/activate4. Install Dependencies
You'll need the official API wrappers for both platforms.
pip install spotipy google-api-python-client google-auth-oauthlibConfiguration and API Keys
The script relies on OAuth2 for authentication. You cannot skip the developer portal setup:
- Spotify: Create an app in the Spotify Developer Dashboard to get your
CLIENT_IDandCLIENT_SECRET. Set your Redirect URI tohttp://localhost:8888/callback. - YouTube: Create a project in the Google Cloud Console, enable the YouTube Data API v3, and download the
client_secrets.jsonfile.
Store these in a
.env file rather than hardcoding them into your script:SPOTIPY_CLIENT_ID='your_spotify_id'
SPOTIPY_CLIENT_SECRET='your_spotify_secret'
SPOTIPY_REDIRECT_URI='http://localhost:8888/callback'Running this locally allows for a much faster AI workflow when iterating on the prompt engineering side of playlist curation, as you can test API calls in real-time without deploying to a staging environment. Once the environment is active, the script handles the token exchange automatically via the browser.