mirror of
https://github.com/M4X809/list-of-lp.git
synced 2025-12-25 19:12:48 +00:00
- Changed track IDs in fetched-songs.json and song-links.json from hyphenated to underscore format for consistency. - Added FontAwesome dependencies to package.json for icon support. - Introduced a new function in fetch-song-links.ts to retrieve song links by ID. - Refactored TrackCard component to utilize the new hash functionality for track modals. - Updated layout.tsx to include FontAwesome styles and configuration. |
||
|---|---|---|
| .. | ||
| fetch-song-links.ts | ||
| README.md | ||
Song Links Fetcher
This script fetches streaming links (Spotify, YouTube, YouTube Music, Apple Music) for all Linkin Park songs in the project using the SongLink API.
Features
- 🎵 Fetches links for all songs from the
list.tsfile using their Spotify URLs - ⏱️ Respects API rate limit (10 requests per minute)
- 💾 Caches already-fetched songs to avoid redundant API calls
- 📁 Outputs both TypeScript and JSON files
- 📊 Shows progress and summary statistics
- ⏭️ Automatically skips songs without Spotify URLs
- 🎨 Automatically formats all generated files with Prettier
Usage
Run the script with:
bun run fetch-links
Output Files
src/lib/songLinks.ts- TypeScript file with exportedsongLinksobjectdata/song-links.json- JSON file with all song linksdata/fetched-songs.json- Cache file tracking which songs have been fetched
Data Structure
The generated TypeScript file exports a songLinks object with this structure:
{
"hybrid-theory-1": {
"spotify": "https://open.spotify.com/track/...",
"youtube": "https://www.youtube.com/watch?v=...",
"youtubeMusic": "https://music.youtube.com/watch?v=...",
"appleMusic": "https://music.apple.com/..."
},
// ... more songs
}
API Information
- API: SongLink/Odesli API
- Endpoint:
https://api.song.link/v1-alpha.1/links - Parameters:
url: Spotify track URL (encoded)userCountry: DE (Germany)songIfSingle: true (for better matching)
- Rate Limit: 10 requests per minute
- Delay between requests: 6 seconds
Requirements
Each track in list.ts must have a __SPOTIFY_URL__ field with a valid Spotify track URL. Tracks without this field will be automatically skipped.
Resumable
If the script is interrupted or fails for any song, you can simply run it again. It will:
- Skip already-fetched songs (based on the cache file)
- Continue fetching remaining songs
- Preserve all previously fetched data
Clearing Cache
To re-fetch all songs from scratch, delete the cache file:
rm data/fetched-songs.json