# Spotify Top Tracks CLI Find the most popular songs for any artist, or scrape a concert/festival webpage to discover artists and their top tracks. ## Working directory ``` /Users/oabrivard/Projects/javascript/song-popularity ``` ## Commands ### 1. Top tracks for a single artist ```bash node get_popularity.js "Artist Name" node get_popularity.js "Artist Name" --top 5 ``` Output (stdout, JSON): ```json { "artist": "Radiohead", "tracks": [ { "name": "Creep", "album": "Pablo Honey", "uri": "spotify:track:..." }, { "name": "No Surprises", "album": "OK Computer", "uri": "spotify:track:..." }, { "name": "Let Down", "album": "OK Computer", "uri": "spotify:track:..." } ] } ``` ### 2. Scrape a URL and get top tracks for each artist ```bash node get_popularity.js --url "https://www.example-festival.com/lineup" --llm anthropic node get_popularity.js --url "https://www.example-festival.com/lineup" --llm openai --top 5 ``` Output (stdout, JSON): ```json { "artists": [ { "artist": "The Cure", "tracks": [ { "name": "Friday I'm in Love", "album": "Wish", "uri": "spotify:track:..." } ] }, { "artist": "Radiohead", "tracks": [ { "name": "Creep", "album": "Pablo Honey", "uri": "spotify:track:..." } ] } ] } ``` ### 3. Scrape + create a Spotify playlist ```bash node get_popularity.js --url "https://www.example-festival.com/lineup" --llm anthropic --create_playlist ``` Adds a `playlist` field to the output: ```json { "artists": [ ... ], "playlist": { "name": "www.example-festival.com_lineup", "url": "https://open.spotify.com/playlist/..." } } ``` Note: `--create_playlist` requires browser-based Spotify OAuth authorization. ## Parameters | Parameter | Required | Default | Description | |---|---|---|---| | (positional) | No | "Radiohead" | Artist name (single artist mode) | | `--url` | No | - | URL to scrape for artist names | | `--top N` | No | 3 | Number of top tracks per artist | | `--llm` | No | anthropic | LLM provider for scraping (`anthropic` or `openai`) | | `--create_playlist` | No | - | Create a Spotify playlist (requires `--url`) | ## Notes - Progress messages go to stderr; JSON result goes to stdout - Use `2>/dev/null` to suppress progress messages - The Spotify API is rate-limited to 2 requests per second