A SvelteKit application that fetches Spotify playlists and extracts song information for generating bingo cards.
- π΅ Fetch complete Spotify playlists using just a link
- π Extract all song names, artists, and metadata
- π― Backend API for playlist data retrieval
- β‘ Built with SvelteKit and TypeScript
- π¨ Clean, dark-themed UI
Before you begin, you'll need:
- Node.js (v18 or higher)
- pnpm (or npm/yarn)
- Spotify Developer Account with API credentials
git clone <repository>
cd spotify_bingo_creator
pnpm install- Go to Spotify Developer Dashboard
- Create a new application
- Accept the terms and create the app
- You'll get:
- Client ID
- Client Secret
- Set the Redirect URI to
https://dvnl.work(or your own if different)
Use the Python script from your portfolio repository or follow this process:
- Create an authorization URL:
https://accounts.spotify.com/authorize?client_id=YOUR_CLIENT_ID&response_type=code&redirect_uri=https://dvnl.work&scope=playlist-read-private%20playlist-read-collaborative
- Visit the URL and authorize the application
- You'll be redirected and the authorization code will be in the URL
- Exchange the code for tokens:
curl -X POST https://accounts.spotify.com/api/token \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=authorization_code&code=YOUR_AUTH_CODE&redirect_uri=https://dvnl.work&client_id=YOUR_CLIENT_ID&client_secret=YOUR_CLIENT_SECRET"- Extract the
refresh_tokenfrom the response
If you have the script from your portfolio:
python3 scripts/get_spotify_token.py- Copy
.env.exampleto.env:
cp .env.example .env- Fill in your credentials:
SPOTIFY_CLIENT_ID=your_client_id_here
SPOTIFY_CLIENT_SECRET=your_client_secret_here
SPOTIFY_REFRESH_TOKEN=your_refresh_token_herepnpm devVisit http://localhost:5173 in your browser.
- Open the application in your browser
- Paste a Spotify playlist link (e.g.,
https://open.spotify.com/playlist/PLAYLIST_ID) - Click "Fetch" to load all songs
- View the complete song list with artist names and durations
Endpoint: POST /api/playlist
Request:
{
"playlistLink": "https://open.spotify.com/playlist/PLAYLIST_ID"
}Response:
{
"success": true,
"data": {
"id": "PLAYLIST_ID",
"name": "Playlist Name",
"description": "Playlist description",
"ownerName": "Owner Name",
"totalTracks": 50,
"playlistLink": "https://open.spotify.com/playlist/...",
"songs": [
{
"id": "TRACK_ID",
"name": "Song Name",
"artist": "Artist Name",
"artists": ["Artist Name"],
"uri": "spotify:track:TRACK_ID",
"link": "https://open.spotify.com/track/...",
"image": "https://...",
"durationMs": 180000
}
]
}
}src/
βββ lib/
β βββ interfaces/
β β βββ spotify.interface.ts # Spotify API types
β βββ server/
β β βββ spotify.ts # Backend Spotify service
β βββ assets/
βββ routes/
β βββ api/
β β βββ playlist/
β β βββ +server.ts # Playlist API endpoint
β βββ +page.svelte # Main UI
βββ app.css # Global styles
βββ app.html # HTML entry point
Fetches a complete playlist by link and returns all track information.
Parameters:
playlistLink: Full Spotify playlist URL orspotify:playlist:IDURI
Returns: PlaylistData object containing playlist info and all tracks
Example:
import { getPlaylistFromLink } from '$lib/server/spotify';
const playlist = await getPlaylistFromLink('https://open.spotify.com/playlist/PLAYLIST_ID');
console.log(`Loaded ${playlist.songs.length} songs from "${playlist.name}"`);Extracts the playlist ID from a Spotify link.
Supported formats:
https://open.spotify.com/playlist/PLAYLIST_IDhttps://open.spotify.com/playlist/PLAYLIST_ID?si=...spotify:playlist:PLAYLIST_ID
pnpm buildThe build output will be in the .svelte-kit/output directory.
The application accepts:
- Web URLs:
https://open.spotify.com/playlist/PLAYLIST_ID - Web URLs with parameters:
https://open.spotify.com/playlist/PLAYLIST_ID?si=xxxxx - Spotify URIs:
spotify:playlist:PLAYLIST_ID
- Make sure you have a
.envfile with all required credentials - Run
pnpm devto rebuild the environment types
- Verify the playlist link is correct
- Check if the playlist is set to private (you need playlist-read-private scope)
- You're making too many requests to Spotify API
- Wait a few seconds before trying again
- Your refresh token has expired or is invalid
- Re-generate a new token following the Setup Instructions
- SvelteKit - Modern web framework
- TypeScript - Type-safe JavaScript
- Tailwind CSS - Utility-first CSS
- Spotify Web API - Playlist and track data
- Node.js - Backend runtime
MIT