A Rust-based application that allows users to request YouTube songs by title. The app retrieves the closest YouTube video match using the YouTube Data API and manages song queues with playlist support and smart recommendations.
- Add songs by title and retrieve the closest matching YouTube video
- Store video titles and URLs in a local SQLite database
- Manage song queue (add, delete, and play songs in order)
- YouTube Player integration for autoplaying requested videos
- Playlist support: When the queue is empty, play songs from a chosen playlist
- Smart recommendations that avoid compilations and recently played songs
- Playlist Queue: Separate queue for playlist songs with automatic cleanup
- Pagination: Fetch unlimited songs from YouTube playlists (up to 1000)
- Fallback System: Main queue → Playlist queue → Recommendations
- No YouTube Shorts: Filters out short-form content and very short videos
- Rust (latest stable version)
- YouTube Data API key
- Go to the Google Cloud Console
- Create a new project or select an existing one
- Enable the YouTube Data API v3
- Create credentials (API Key)
- Copy the API key for use in your
.envfile
- Clone or download this repository
- Copy the example environment file:
cp .env.example .env
- Edit
.envand add your YouTube API key:YOUTUBE_API_KEY=your_actual_youtube_api_key_here - Install dependencies:
cargo build
-
Start the server:
cargo run
-
Access the application:
- Requester page: http://localhost:420/ (for users to request songs)
- Host page: http://localhost:420/host (for managing the queue and playlists)
| Endpoint | Method | Description |
|---|---|---|
/ |
GET | Loads the requester frontend |
/host |
GET | Loads the host frontend |
/url |
POST | Adds a new song to the queue |
/url |
DELETE | Removes a song from the queue |
/url/oldest |
GET | Gets and deletes the oldest song |
/urls |
GET | Lists all songs in the queue |
/recommendation |
GET | Gets a recommended video |
| Endpoint | Method | Description |
|---|---|---|
/playlist-queue |
POST | Add songs from YouTube playlist URL |
/playlist-queue |
GET | Get all songs in playlist queue |
/playlist-queue |
DELETE | Clear playlist queue |
| Endpoint | Method | Description |
|---|---|---|
/playlists |
GET | Lists all playlists |
/playlists |
POST | Creates a new playlist |
/playlists/{id} |
GET | Gets a specific playlist |
/playlists/{id}/items |
POST | Adds a song to a playlist |
/playlists/{id}/items |
GET | Gets all items in a playlist |
/playlists/{id}/random |
GET | Gets a random item from a playlist |
The application follows a strict priority order:
- Main Queue: User-requested songs (highest priority)
- Playlist Queue: Songs from YouTube playlists (fallback when main queue is empty)
- Recommendations: YouTube recommendations (only when both queues are empty)
- Simple URL Input: Just paste a YouTube playlist URL
- Automatic Fetching: Fetches all songs from the playlist (up to 1000 songs)
- Auto-cleanup: Songs are automatically removed after being played
- No Duplicates: Each song plays only once
- Real-time Updates: Frontend automatically refreshes when songs are played
- requester.html: Allows users to add songs to the queue by entering a song title
- host.html: Displays both main queue and playlist queue, includes playlist URL input and management
- Go to http://localhost:420/ (requester page)
- Enter a song title and your name
- The system will find the closest YouTube match and add it to the queue
- Go to http://localhost:420/host (host page)
- Paste a YouTube playlist URL in the "Add Playlist" section
- Click "Add All Songs" to fetch all songs from the playlist
- Songs will automatically play when the main queue is empty
- Main Queue: User-requested songs play first
- Playlist Queue: Plays when main queue is empty
- Automatic Cleanup: Played songs are removed automatically
- Real-time Updates: Interface updates automatically
- Never commit your
.envfile: It contains your API key and should remain private - The
.env.examplefile is safe to commit: It only contains placeholder values - API Key Security: Keep your YouTube API key secure and don't share it publicly
- Error loading API key: Make sure the
.envfile is correctly set up in the root directory - YouTube API errors: Ensure your API key is valid and has access to the YouTube Data API v3
- Database errors: The SQLite database will be created automatically on first run
- Playlist not loading: Check that the YouTube playlist URL is public and accessible
This project is licensed under the MIT License.