A powerful, full-featured Spotify playlist manager with a stunning interactive CLI and automated bot for rule-based playlist management.
- List all playlists with track counts, visibility, and owner info
- View tracks with paginated browsing (50 per page)
- Create new playlists
- Edit playlist name, description, and visibility
- Clone any playlist (full deep copy)
- Remove tracks interactively with multi-select
- Shuffle playlists with smart artist separation
- Merge multiple playlists into one (with dedup)
- Delete (unfollow) playlists
- Follow / Unfollow playlists by ID or URL
- Search the Spotify catalog and add results to any playlist
- Quick search for fast lookups with popularity stars
- Playlist stats โ duration, popularity, top artists, decade breakdown, diversity metrics
- Audio analysis โ danceability, energy, valence, acousticness, tempo, key distribution
- Library overview โ total playlists, tracks, public/private split, largest playlists
- Export playlists to JSON or CSV
- Import playlists from JSON files
- Full backup of all playlists to a single timestamped file
- Restore from backup โ recreates playlists and re-adds all tracks
| Rule | Description |
|---|---|
| โค๏ธ Add Liked Songs | Auto-add recently liked songs to a playlist |
| ๐๏ธ Remove Unplayed | Remove tracks not played in X days |
| ๐ Sync Playlists | Mirror or append from one playlist to another |
| ๐ฎ Discover Clone | Archive each week's Discover Weekly |
| ๐งน Deduplicate | Remove duplicate tracks (keep first or last) |
| ๐ Sort Playlist | Sort by name, artist, date, popularity, or duration |
| ๐ Top Tracks | Auto-fill your top tracks into a playlist |
| ๐ Auto-Shuffle | Smart shuffle with artist separation |
| ๐ก Recommendations | Generate recs from a seed playlist |
- Cron scheduling โ runs rules automatically (configurable schedule)
- Dry-run mode โ preview changes without modifying Spotify
- Run history โ every execution is logged and auditable
Run commands without entering the interactive menu:
npm run dev -- list # List all playlists
npm run dev -- search "daft punk" # Search tracks
npm run dev -- stats # Library overview
npm run dev -- backup # Backup all playlists
npm run dev -- export <playlistId> # Export a playlist to JSON- Node.js 20+ installed (download)
- A Spotify Developer account โ Create one here
- Go to https://developer.spotify.com/dashboard
- Click Create App
- Set the Redirect URI to:
http://localhost:8888/callback - Note your Client ID and Client Secret
git clone https://github.com/ColinGamez/SpotiB0T.git
cd SpotiB0T
npm install
# Copy the example env file and fill in your credentials
cp .env.example .envEdit .env with your Spotify app credentials:
SPOTIFY_CLIENT_ID=your_client_id_here
SPOTIFY_CLIENT_SECRET=your_client_secret_herenpm run devOn first launch the app opens your browser for Spotify login. After authorizing, tokens are stored securely in a local SQLite database and auto-refresh.
The interactive menu is organized into clear sections:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ SpotiB0T ยท Playlist Manager & Bot โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Logged in as: YourName
โโโ PLAYLISTS โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
List my playlists
View playlist tracks
Create new playlist
Edit playlist details
Clone a playlist
Remove tracks
Shuffle a playlist
Merge playlists
Delete a playlist
Follow / Unfollow
โโโ SEARCH โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Search & add tracks
Quick search
โโโ ANALYTICS โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Playlist stats
Library overview
โโโ EXPORT & BACKUP โโโโโโโโโโโโโโโโโโโโโโโโโ
Export playlist (JSON/CSV)
Import playlist
Backup all playlists
Restore from backup
โโโ AUTOMATION โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
List rules
Add rule
Run a rule
Toggle rule
Delete rule
View run history
Logout
# Run all enabled rules once
npm run dev -- --once
# Run in cron mode (stays alive, executes on schedule)
npm run dev -- --bot
# Dry-run mode
DRY_RUN=true npm run dev -- --oncesrc/
โโโ auth/ # OAuth 2.0 authentication
โ โโโ oauth.ts # Authorization Code Flow with PKCE-ready server
โ โโโ tokenStore.ts # Token persistence (SQLite)
โ โโโ login.ts # Standalone login script
โ โโโ index.ts # Barrel export
โโโ spotify/ # Spotify Web API layer
โ โโโ apiClient.ts # Axios client with retry, rate-limit, token refresh
โ โโโ playlistService.ts # 20+ playlist/library operations
โ โโโ types.ts # TypeScript interfaces for Spotify objects
โ โโโ index.ts
โโโ rules/ # Automation engine
โ โโโ types.ts # Rule type definitions (9 types)
โ โโโ ruleStore.ts # Rule CRUD (SQLite)
โ โโโ ruleExecutor.ts # Rule dispatch & execution handlers
โ โโโ index.ts
โโโ bot/ # Scheduled runner
โ โโโ runner.ts # Cron-based automation + run-once mode
โ โโโ index.ts
โโโ commands/ # CLI command handlers
โ โโโ playlistCommands.ts # 10 playlist operations
โ โโโ searchCommands.ts # Search & quick search
โ โโโ statsCommands.ts # Playlist stats & library overview
โ โโโ exportCommands.ts # Export, import, backup, restore
โ โโโ ruleCommands.ts # Rule wizard, toggle, run, delete, history
โ โโโ index.ts # Barrel export
โโโ utils/ # Shared utilities
โ โโโ config.ts # Validated environment config
โ โโโ db.ts # SQLite database (better-sqlite3)
โ โโโ logger.ts # Winston logging (console + file)
โ โโโ format.ts # CLI formatting helpers (tables, bars, stars)
โ โโโ spinner.ts # ora spinner wrapper
โ โโโ sleep.ts # Async delay helper
โโโ cli.ts # Interactive CLI (inquirer menus)
โโโ index.ts # Entry point โ CLI / Bot / Direct command router
All config lives in .env:
| Variable | Description | Default |
|---|---|---|
SPOTIFY_CLIENT_ID |
Your Spotify app Client ID | required |
SPOTIFY_CLIENT_SECRET |
Your Spotify app Client Secret | required |
SPOTIFY_REDIRECT_URI |
OAuth callback URL | http://localhost:8888/callback |
DRY_RUN |
Preview mode โ no Spotify writes | false |
LOG_LEVEL |
Logging verbosity (debug / info / warn / error) |
info |
DB_PATH |
SQLite database file path | ./data/spotify-bot.db |
CRON_SCHEDULE |
Bot execution schedule (cron syntax) | 0 * * * * (hourly) |
- CLI โ Add rule โ Add liked songs
- Select target playlist, set days:
7 - Run it manually or let the bot handle it on schedule
- CLI โ Add rule โ Sync playlists
- Source: Playlist A โ Target: Playlist B โ Mode: Mirror
- Enable the bot:
npm run dev -- --bot
- CLI โ Add rule โ Clone Discover Weekly
- Set
CRON_SCHEDULE=0 9 * * 1in.env - Run:
npm run dev -- --bot
- CLI โ Add rule โ Top tracks
- Select time range and target playlist
- The bot updates it on every run
- Dry-run mode โ preview all changes before committing
- Duplicate detection โ tracks already in a playlist are never re-added
- Rate-limit handling โ automatic exponential backoff on Spotify 429s (capped at 10 retries)
- Retry logic โ handles 401, 5xx, and network errors with exponential backoff
- Token auto-refresh โ never worry about expired tokens
- Graceful shutdown โ SIGINT handler cleanly closes the database
- Audit trail โ every rule run is logged with status, summary, and timestamp
- Error recovery โ corrupted rule configs are handled gracefully (fallback defaults)
| Command | Description |
|---|---|
npm run dev |
Start interactive CLI (with ts-node) |
npm run dev -- --bot |
Start cron-based bot |
npm run dev -- --once |
Run all rules once and exit |
npm run dev -- list |
List playlists (direct) |
npm run dev -- search "query" |
Search tracks (direct) |
npm run dev -- stats |
Library overview (direct) |
npm run dev -- backup |
Backup all playlists (direct) |
npm run dev -- export <id> |
Export playlist (direct) |
npm run build |
Compile TypeScript to dist/ |
npm start |
Run compiled JS from dist/ |
npm run lint |
Run ESLint |
| Component | Technology |
|---|---|
| Runtime | Node.js 20+ / TypeScript 5.9 |
| API | Spotify Web API (Authorization Code Flow) |
| Database | SQLite via better-sqlite3 |
| CLI | Inquirer.js + Chalk + ora spinners |
| Scheduling | node-cron |
| HTTP | Axios with retry interceptors |
| Logging | Winston (console + file) |
| Linting | ESLint 9 (flat config) + typescript-eslint |
MIT