Skip to content

Patdabaker/chartsync

Repository files navigation

🎡 ChartSync

Billboard β†’ Spotify Playlist Generator

ChartSync is a full-stack web application that lets users transform any Billboard chart into a fully generated Spotify playlist β€” customized, editable, and built using real historical chart data.

The user selects a chart, date range, number of songs, and ChartSync automatically builds a playlist, lets the user edit it inline, and then adds it directly to their Spotify account using OAuth authentication.


πŸš€ Features

πŸ“Š Billboard Chart Integration

  • Pulls tracks from multiple Billboard charts (Hot 100, Billboard 200, Radio, etc.)
  • Dynamically restricts date ranges based on each chart’s actual data
  • CSV parsing with Pandas to extract song data

πŸ“ Playlist Builder

  • Generates a playlist from chart rankings for a chosen date range
  • Duplicate handling + β€œomit song” support
  • Per-track album art, title, and artist info
  • Tracks missing album art use a fallback default image

πŸ—‚οΈ Interactive Editing

  • Delete songs by clicking checkbox
  • Regenerate playlist without removed songs
  • No page refresh β€” everything async via fetch() + JSON

🎧 Spotify Login & Playlist Upload

  • OAuth login with Spotipy & Spotify API
  • Tokens securely stored in session
  • Automatic token refresh
  • Create playlist on the user’s Spotify account
  • Batch add tracks for large playlists
  • Returns songs that failed to match Spotify’s catalog

⚑ Fully Asynchronous Frontend

  • JS fetch calls β†’ Flask backend β†’ JSON responses
  • Loading states, error handling, and dynamic UI updates
  • Responsive β€œresults window” that scrolls independently
  • Reset, regenerate, and add-to-Spotify actions

🎨 Styled UI

  • Modern Spotify-inspired design
  • Centered header layout with right-aligned login/profile
  • Responsive layout
  • (CSS delivered separately)

πŸ› οΈ Tech Stack

Frontend

  • HTML5, CSS3
  • Vanilla JavaScript (async + fetch API)
  • Dynamic DOM updates and event-driven UI

Backend

  • Python 3
  • Flask (routes, sessions, JSON API endpoints)
  • Spotipy (Spotify API client)
  • Pandas (CSV/chart parsing)

Infrastructure

  • Virtual environment (venv)
  • Gunicorn (production server)
  • Procfile for deployment
  • Environment variables via .env

πŸ“š How It Works

1. User Selects Chart + Date Range

JS updates date min/max dynamically based on chart metadata derived from CSV.

2. User Submits β†’ Async Request

Payload sent as JSON:

{
  "chart": "Hot 100",
  "start": "2024-01-01",
  "end": "2024-02-01",
  "name": "My Playlist",
  "amount": 50,
  "omit": [],
  "songs": []
}

3. Flask Generates Playlist

  • Reads chart CSV
  • Filters by date
  • Picks top N songs
  • Removes omitted songs
  • Returns a structured JSON list of tracks

4. User Edits Playlist

  • Checkboxes auto-select the entire row
  • Deleted songs get pushed into the omit list

5. Add to Spotify

  • OAuth login required
  • Application creates playlist under the user’s Spotify account
  • Adds track URIs in batches
  • Returns any tracks not found by Spotify

πŸ§ͺ Local Development Setup

1. Clone Repo

git clone https://github.com/Patdabaker/chartsync.git
cd chartsync

2. Create Virtual Environment

python -m venv venv
source venv/bin/activate   # Mac/Linux
venv\Scripts\activate      # Windows

3. Install Dependencies

pip install -r requirements.txt

4. Assign Environment Variables

Create .env:

FLASK_SECRET_KEY=your-secret
SPOTIFY_CLIENT_ID=your-client-id
SPOTIFY_CLIENT_SECRET=your-client-secret
SPOTIFY_REDIRECT_URI=http://127.0.0.1:5000/callback
SPOTIFY_SCOPE='playlist-modify-private playlist-modify-public'

5. Run Flask

flask run

🌐 Deployment

ChartSync supports deployment via:

βœ” Fly.io

βœ” Render

βœ” Railway

βœ” Heroku-equivalent platforms (Gunicorn + Procfile)

Your Procfile typically contains:

web: gunicorn app:app

🧩 Project Structure

chartsync/
β”‚
β”œβ”€β”€ app.py               # Flask backend
β”œβ”€β”€ generate.py          # Chart parsing + playlist logic
β”œβ”€β”€ static/
β”‚   β”œβ”€β”€ images/
β”‚   β”‚   └── default_art.png
β”‚   β”œβ”€β”€ css/
β”‚   β”‚   └── styles.css
β”‚   └── main.js
β”œβ”€β”€ templates/
β”‚   β”œβ”€β”€ base.html
β”‚   └── index.html
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ Procfile
└── README.md

🚧 Future Enhancements

These are optional upgrade ideas:

  • OAuth auto-refresh UI
  • Multi-chart mixed playlists
  • Genre filtering
  • β€œInclude featured artists” toggle
  • Shareable playlist preview page
  • Light/Dark theme toggle
  • More Spotify-like UI components
  • Mobile responsive optimization
  • Background task queue for long operations
  • Cloud caching (Redis)

πŸ“„ License

MIT License β€” feel free to fork, remix, and build upon!


πŸ™Œ Acknowledgements

  • Billboard for chart data
  • Spotify API + Spotipy
  • CS50x (project inspiration)
  • Album art sources from dataset

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published