A Python toolkit for collecting and analyzing song data from various music platforms. This toolkit allows you to:
- Get song popularity, audio features, and metadata from Spotify
- Retrieve view counts from YouTube
- Find and clean song lyrics from Genius
- Store and update all data in Google Sheets
- Spotify Integration: Get song popularity, tempo, energy, danceability, and more
- YouTube Stats: Look up view counts for music videos
- Lyrics Retrieval: Get cleaned lyrics from Genius
- Google Sheets Integration: Read and update song data in spreadsheets
-
Clone this repository
-
Set up a virtual environment (recommended):
Windows:
python -m venv venv venv\Scripts\activate
macOS/Linux:
python -m venv venv source venv/bin/activate
-
Install the required packages:
pip install -r requirements.txt
-
Set up your API credentials (see Configuration section)
You can configure the toolkit in two ways:
Create a .env
file in the project root with the following variables:
SPOTIFY_CLIENT_ID=your_spotify_client_id
SPOTIFY_CLIENT_SECRET=your_spotify_client_secret
GENIUS_ACCESS_TOKEN=your_genius_token
YOUTUBE_API_KEY=your_youtube_key
GOOGLE_SHEETS_CREDENTIALS_FILE=path/to/credentials.json
Copy config_example.py
to config.py
and fill in your credentials:
SPOTIFY_CLIENT_ID = "your_spotify_client_id"
SPOTIFY_CLIENT_SECRET = "your_spotify_client_secret"
GENIUS_ACCESS_TOKEN = "your_genius_token"
YOUTUBE_API_KEY = "your_youtube_key"
GOOGLE_SHEETS_CREDENTIALS_FILE = "path/to/credentials.json"
-
Create a Google Sheet with at minimum these columns:
artist_name
(required)song_title
(required)- Additional columns will be auto-populated:
track_id
,song_popularity
,duration
,tempo_spotify
,energy
,danceability
,artist_id
,year
,youtube_views
,lyrics
, etc.
-
Share your Google Sheet with the email address from your service account credentials. Give it the role of "Editor".
python songdata.py "Your Spreadsheet Name" "Sheet1"
This will collect data from all available sources (Spotify, YouTube, and Genius lyrics).
spreadsheet
: Name of your Google Sheetworksheet
: Name or index of the worksheet (0 for first sheet)--methods
: Data to collect (spotify, youtube, lyrics, or any combination)- If omitted, all methods (spotify, youtube, lyrics) will be used by default
--start-row
: Row to start from (0-based, after headers)--config
: Path to config file if using Option 2 for configuration
# Use all methods (default)
python songdata.py "Weezer Setlist" 0
# Use only specific methods
python songdata.py "Weezer Setlist" 0 --methods spotify youtube
You can also import and use the toolkit in your own Python scripts. See the examples directory for sample code.
You'll need to set up accounts and obtain API keys for: