A powerful and flexible radio broadcasting system that supports multiple music streaming platforms with real-time streaming capabilities. Stream music from various sources and manage queues dynamically with live audio broadcasting.
- Multi-platform Music Streaming Support:
- 🎵 JioSaavn - Indian music streaming
- 🎬 YouTube - Video/audio content
- 🎧 SoundCloud - Independent artists and tracks
- 🎶 Spotify - Metadata and search integration
- Dual Streaming Support - Icecast server integration + direct HTTP MP3 streaming
- Professional Broadcasting - Icecast-compatible streaming with metadata support
- Smart Queue Management - Dynamic song queuing with priority control
- WebSocket Integration - Live updates for connected clients
- Intelligent Caching System - Automatic file caching with size management
- Block List Management - Content filtering and moderation
- Default Playlist System - Automated fallback music rotation
- Metadata Enrichment - Spotify-powered song information
- Token-based Authentication - Secure access control
- Admin Panel Controls - Administrative song and user management
- Docker Containerization - Easy deployment and scaling
- Smart Fallback System - Automatic track switching when queue is empty
- Configurable Settings - Runtime configuration management
- Node.js (v18 or higher)
- FFmpeg (for audio processing and streaming)
- Docker (optional, for containerized deployment)
- Icecast Server (optional, for professional broadcasting)
- API Keys for music platforms:
- Spotify Client ID & Secret (for metadata)
- SoundCloud API Key (for SoundCloud integration)
- Clone the repository:
git clone https://github.com/GauravGhost/MRadio
cd MRadio- Install dependencies:
npm install- Configure environment variables:
Create a
.envfile in the root directory with the following variables:
# Server Configuration
PORT=9126
NODE_ENV=development
FFMPEG_ENV=production
# Music Platform API Keys
SPOTIFY_CLIEND_ID=your_spotify_client_id
SPOTIFY_CLIEND_SECRET_ID=your_spotify_client_secret
SOUNDCLOUD_API_KEY=your_soundcloud_api_key
# Admin Authentication
X_ADMIN_API_KEY=your_admin_api_key
X_ADMIN_TOKEN_KEY=your_admin_token_key
# Icecast Server Configuration (Optional)
ICECAST_HOST=localhost
ICECAST_PORT=8000
ICECAST_PASSWORD=your_icecast_password
ICECAST_MOUNT=/radio.mp3
ICECAST_NAME=MRadio
ICECAST_DESCRIPTION=MRadio - Multi-platform Music Streaming
ICECAST_GENRE=Various
ICECAST_BITRATE=128
# Initial Default Playlist (Optional)
INITIAL_PLAYLIST_ID=playlist_id
INITIAL_PLAYLIST_SOURCE=youtube|jiosaavn|soundcloud
INITIAL_PLAYLIST_TITLE=playlist_title- Create required directories:
mkdir -p cache data logs media/tracks media/fallback config- Start the server:
npm start- Clone the repository:
git clone https://github.com/GauravGhost/MRadio
cd MRadio-
Configure environment variables: Create a
.envfile with the required variables (same as above). -
Build and run with Docker:
# Using the provided script
./run.sh
# Or manually
docker compose up -d# Stop any existing containers and rebuild
docker compose down --rmi all
docker compose build
docker compose up -dMRadio supports professional broadcasting through Icecast server integration, providing a standards-compliant streaming solution with proper metadata support.
- Create Icecast Docker container:
docker run -d --name icecast \
-p 8000:8000 \
-e ICECAST_ADMIN_PASSWORD=admin123 \
-e ICECAST_SOURCE_PASSWORD=source123 \
-e ICECAST_RELAY_PASSWORD=relay123 \
moul/icecast- Configure MRadio environment variables:
ICECAST_HOST=localhost
ICECAST_PORT=8000
ICECAST_PASSWORD=source123
ICECAST_MOUNT=/radio.mp3
ICECAST_NAME=MRadio
ICECAST_DESCRIPTION=MRadio - Multi-platform Music Streaming
ICECAST_GENRE=Various
ICECAST_BITRATE=128Ubuntu/Debian:
sudo apt-get update
sudo apt-get install icecast2macOS:
brew install icecastConfiguration:
Edit /etc/icecast2/icecast.xml (Linux) or /usr/local/etc/icecast.xml (macOS):
<icecast>
<listen-socket>
<port>8000</port>
</listen-socket>
<authentication>
<source-password>your_source_password</source-password>
<admin-password>your_admin_password</admin-password>
</authentication>
<mount>
<mount-name>/radio.mp3</mount-name>
<username>source</username>
<password>your_source_password</password>
<max-listeners>100</max-listeners>
<dump-file>/var/log/icecast2/radio.dump</dump-file>
<burst-on-connect>1</burst-on-connect>
<mp3-metadata-interval>8192</mp3-metadata-interval>
</mount>
</icecast>Start Icecast:
# Linux
sudo systemctl start icecast2
sudo systemctl enable icecast2
# macOS
brew services start icecast- Professional Broadcasting: Standards-compliant streaming protocol
- Metadata Support: Song titles, artists, and album information
- Multiple Listeners: Support for concurrent connections
- Auto-Reconnection: Automatic reconnection on network issues
- Fallback Support: Graceful fallback to direct HTTP streaming
- Status Monitoring: Real-time connection and streaming status
Once configured, your streams will be available at:
- Icecast Stream:
http://your-server:8000/radio.mp3 - Direct HTTP Stream:
http://your-server:9126/stream - Icecast Admin Panel:
http://your-server:8000/admin/
-
Connection Refused
- Verify Icecast server is running:
netstat -tlnp | grep :8000 - Check firewall settings
- Verify ICECAST_HOST and ICECAST_PORT configuration
- Verify Icecast server is running:
-
Authentication Failed
- Verify ICECAST_PASSWORD matches source password in icecast.xml
- Check mount point configuration
-
No Audio Stream
- Check FFmpeg installation and permissions
- Verify mount point exists in Icecast configuration
- Check logs:
docker logs icecastor/var/log/icecast2/
Check Icecast status via API:
curl -X GET http://localhost:9126/api/icecast/statusResponse includes:
- Connection status
- Stream information
- Listener count
- Bitrate and quality metrics
npm startThe server will start on port 9126 by default.
docker compose up -dhttp://your-icecast-server:8000/radio.mp3
High-quality streaming with proper metadata support for media players and broadcasting tools.
http://localhost:9126/stream
Direct access to the MP3 audio stream for simple media player integration.
http://localhost:9126/
Redirects to the stream endpoint for immediate playback.
- Generate User Token (Admin required):
curl -X POST http://localhost:9126/api/admin/token \
-H "Content-Type: application/json" \
-H "x-admin-api-key: YOUR_ADMIN_API_KEY" \
-H "x-admin-token-key: YOUR_ADMIN_TOKEN_KEY" \
-d '{"username": "your_username"}'- Use Token for API Requests:
# Add token to headers for authenticated endpoints
-H "x-token-key: YOUR_GENERATED_TOKEN"curl -X POST http://localhost:9126/api/songs/add \
-H "Content-Type: application/json" \
-d '{"songName": "Shape of You Ed Sheeran", "requestedBy": "user1"}'curl -X GET http://localhost:9126/api/songs/skip \
-H "x-token-key: YOUR_TOKEN"curl -X GET http://localhost:9126/api/songs/currentcurl -X GET http://localhost:9126/api/songs/queuecurl -X GET http://localhost:9126/api/icecast/statusStart the server in development mode:
npm startFor production:
npm startBuild and run using Docker Compose:
docker-compose up --buildAll protected endpoints require a user token in the request headers:
x-token-key: YOUR_GENERATED_TOKEN
Admin endpoints require additional authentication:
x-admin-api-key: YOUR_ADMIN_API_KEY
x-admin-token-key: YOUR_ADMIN_TOKEN_KEY
GET /api/songs/current
Description: Get the currently playing song information
GET /api/songs/upcoming
Description: Get information about the next song in queue
GET /api/songs/queue
Description: Get the complete list of songs in the queue
GET /api/icecast/status
Description: Get Icecast server status and streaming informationPOST /api/songs/add
Content-Type: application/json
{
"songName": "Artist - Song Title",
"requestedBy": "username",
"force": false,
"preference": "youtube|jiosaavn|soundcloud"
}
Description: Add a song to the queueGET /api/songs/skip
Description: Skip the current song
GET /api/songs/previous
Description: Play the previous song
GET /api/songs/seek/:seconds
Description: Seek to a specific time in the current song
POST /api/songs/add/top
Content-Type: application/json
{
"songName": "Artist - Song Title",
"requestedBy": "username"
}
Description: Add a song to the top of the queue (priority)
DELETE /api/songs/remove/:index
Description: Remove a song from the queue at specified index
DELETE /api/songs/requests/last/:requestedBy
Description: Remove the last song requested by a specific userPOST /api/playlist/add
Content-Type: application/json
{
"source": "youtube|jiosaavn",
"playlistId": "playlist_id",
"requestedBy": "username"
}
Description: Add an entire playlist to the queue
POST /api/playlist/add/top
Description: Add an entire playlist to the top of the queue
POST /api/playlist/default
Content-Type: application/json
{
"playlistId": "playlist_id",
"title": "Playlist Name",
"source": "youtube|jiosaavn|soundcloud",
"isActive": true,
"genre": "mix|pop|rock|etc"
}
Description: Add a playlist to the default rotation
GET /api/playlist/default
Description: Get all default playlists
DELETE /api/playlist/default/:index
Description: Remove a default playlist by index
PUT /api/playlist/default/:index/status
Content-Type: application/json
{
"isActive": true
}
Description: Update playlist active statusPOST /api/songs/block/current
Content-Type: application/json
{
"requestedBy": "username"
}
Description: Block the currently playing song
POST /api/songs/block
Content-Type: application/json
{
"songName": "Song Title",
"requestedBy": "username"
}
Description: Block a song by its name
DELETE /api/songs/block/:songName
Description: Unblock a song by its name
DELETE /api/songs/block/:index
Description: Unblock a song by its index in the block list
DELETE /api/songs/block/all
Description: Clear the entire block list
GET /api/songs/block/list
Description: Get all blocked songs
GET /api/songs/block/check?songName=Song%20Title
Description: Check if a specific song is blockedGET /api/config?key=configKey
Description: Get configuration value by key
POST /api/config
Content-Type: application/json
{
"key": "defaultPlaylistGenre",
"value": "pop"
}
Description: Update configuration valuesGET /api/icecast/status
Description: Get Icecast server status and streaming information
Response: {
"enabled": true,
"connected": true,
"host": "localhost",
"port": 8000,
"mount": "/radio.mp3",
"listeners": 5,
"status": "streaming"
}POST /api/admin/token
Content-Type: application/json
Headers: x-admin-api-key, x-admin-token-key
{
"username": "new_username"
}
Description: Generate a new user authentication tokenThe server provides real-time updates via Socket.IO:
socket.on('newSong', (songData) => {
// New song started playing
// songData: { title, duration, requestedBy }
});
socket.on('playbackProgress', (progress) => {
// Playback progress update (every 30 seconds)
// progress: { currentTime, duration, percentage }
});
socket.on('queueUpdate', (queueData) => {
// Queue has been modified
});socket.emit('ping'); // Heartbeat check
socket.emit('pong'); // Heartbeat response| Variable | Description | Default | Required |
|---|---|---|---|
PORT |
Server port | 9126 |
No |
NODE_ENV |
Environment mode | development |
No |
FFMPEG_ENV |
FFmpeg environment | development |
No |
SPOTIFY_CLIEND_ID |
Spotify Client ID | - | Yes* |
SPOTIFY_CLIEND_SECRET_ID |
Spotify Client Secret | - | Yes* |
SOUNDCLOUD_API_KEY |
SoundCloud API Key | - | Yes* |
X_ADMIN_API_KEY |
Admin API Key | - | Yes |
X_ADMIN_TOKEN_KEY |
Admin Token Key | - | Yes |
ICECAST_HOST |
Icecast server host | - | No** |
ICECAST_PORT |
Icecast server port | - | No** |
ICECAST_PASSWORD |
Icecast source password | - | No** |
ICECAST_MOUNT |
Icecast mount point | /radio.mp3 |
No |
ICECAST_NAME |
Icecast stream name | MRadio |
No |
ICECAST_DESCRIPTION |
Icecast stream description | MRadio - Multi-platform Music Streaming |
No |
ICECAST_GENRE |
Icecast stream genre | Various |
No |
ICECAST_BITRATE |
Icecast stream bitrate | 128 |
No |
INITIAL_PLAYLIST_ID |
Default playlist ID | - | No |
INITIAL_PLAYLIST_SOURCE |
Default playlist source | - | No |
INITIAL_PLAYLIST_TITLE |
Default playlist title | - | No |
*Required for full functionality, but the server can run with limited features without them. **Required for Icecast streaming. If not provided, the system will fall back to direct HTTP streaming only.
MRadio/
├── server/ # Core server code
│ ├── api/ # REST API routes and controllers
│ ├── lib/ # Platform integrations (YouTube, JioSaavn, etc.)
│ ├── services/ # Business logic services
│ └── utils/ # Utility functions and helpers
├── cache/ # Cached audio files
├── data/ # Runtime data (queues, configs, etc.)
├── logs/ # Application logs
├── media/
│ ├── tracks/ # Temporary downloaded tracks
│ └── fallback/ # Fallback audio files
├── config/ # Configuration files
├── docker-compose.yml # Docker deployment config
├── dockerfile # Docker image config
└── package.json # Node.js dependencies
The application supports runtime configuration through the /api/config endpoints:
defaultPlaylistGenre: Controls which genre of default playlists to use- Values:
"all","pop","rock","mix", etc. - Default:
"mix"
- Values:
The system automatically manages audio file caching:
- Cache Size Limit: 1GB by default
- Location:
./cachedirectory - Cleanup: Automatic when cache exceeds size limit
- Strategy: Least recently used (LRU) eviction
- Format: MP3 streaming at 128 kbps
- FFmpeg: Used for audio processing and streaming
- Bitrate Throttling: Automatic bandwidth management
- Sample Rate: 44.1 kHz, 2 channels (stereo)
MRadio follows a modular, service-oriented architecture designed for scalability and maintainability.
- Express.js REST API server
- FFmpeg audio processing pipeline
- Dual Streaming Support: Icecast + direct HTTP MP3 streaming
- Socket.IO for live client updates
- Automatic Fallback: Direct HTTP streaming when Icecast unavailable
- Dynamic Queue Processing: Real-time song queue management
- Priority System: Support for adding songs to top of queue
- Smart Fallback: Automatic playlist rotation when queue is empty
- Cache Integration: Intelligent file caching with LRU eviction
┌─────────────┐ ┌──────────────┐ ┌─────────────┐
│ YouTube │ │ JioSaavn │ │ SoundCloud │
│ API/YT-DL │ │ API │ │ Scraper │
└─────────────┘ └──────────────┘ └─────────────┘
│ │ │
└───────────────────┼───────────────────┘
│
┌──────────────────┐
│ Metadata Engine │
│ (Spotify API) │
└──────────────────┘
│
┌──────────────────┐
│ Audio Engine │
│ (FFmpeg) │
└──────────────────┘
- JSON-based Storage: Lightweight persistence for queues and configs
- File System Caching: Smart audio file management
- Memory Management: Efficient client connection handling
- Token-based Authentication: 256-bit secure tokens
- Admin Access Control: Separate admin authentication layer
- Request Validation: Input sanitization and validation
┌─────────────────────────────────────────────────────────────┐
│ API Layer │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────────────────┐ │
│ │ Controllers│ │ Middleware │ │ Routes │ │
│ └─────────────┘ └─────────────┘ └─────────────────────────┘ │
└─────────────────────────────────────────────────────────────┘
│
┌─────────────────────────────────────────────────────────────┐
│ Service Layer │
│ ┌──────────────┐ ┌──────────────┐ ┌───────────────────────┐ │
│ │ API Service │ │Config Service│ │ Metadata Service │ │
│ └──────────────┘ └──────────────┘ └───────────────────────┘ │
└─────────────────────────────────────────────────────────────┘
│
┌─────────────────────────────────────────────────────────────┐
│ Core Layer │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────────────────┐ │
│ │Queue Engine │ │Cache Manager│ │ Stream Manager │ │
│ └─────────────┘ └─────────────┘ └─────────────────────────┘ │
└─────────────────────────────────────────────────────────────┘
│
┌─────────────────────────────────────────────────────────────┐
│ Platform Layer │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────────────────┐ │
│ │ YouTube │ │ JioSaavn │ │ SoundCloud │ │
│ └─────────────┘ └─────────────┘ └─────────────────────────┘ │
└─────────────────────────────────────────────────────────────┘
- Factory Pattern: Platform-specific music service instantiation
- Observer Pattern: Real-time client notifications via WebSocket
- Strategy Pattern: Multiple music source handling
- Queue Pattern: FIFO song processing with priority support
- Cache Pattern: LRU audio file caching system
- Stateless Design: Easy horizontal scaling
- Docker Support: Container-based deployment
- Modular Components: Independent service scaling
- Efficient Streaming: Low-latency audio delivery
- Resource Management: Automatic cleanup and optimization
# Ubuntu/Debian
sudo apt-get install ffmpeg
# macOS
brew install ffmpeg
# Or set FFMPEG_ENV=production to use static build# Create directories with proper permissions
mkdir -p cache data logs media/tracks media/fallback config
chmod -R 755 cache data logs media config# Check what's using port 9126
lsof -i :9126
# Kill the process or change PORT in .env
PORT=9127- Verify
.envfile has correct admin keys - Ensure token generation was successful
- Check token is included in request headers
- Verify FFmpeg installation
- Check file permissions in tracks/cache directories
- Ensure adequate disk space for caching
# Check if Icecast server is running
netstat -tlnp | grep :8000
# Test Icecast connection
curl -I http://localhost:8000/
# Check MRadio logs for Icecast errors
tail -f logs/app.log | grep -i icecast- Verify
ICECAST_PASSWORDmatches source password in icecast.xml - Check mount point configuration in Icecast
- Ensure source credentials are correct
- Increase Cache Size: Modify
CACHE_SIZEin constants - Optimize Queue Size: Adjust
DEFAULT_QUEUE_SIZEbased on usage - Monitor Logs: Check
logs/directory for errors - Resource Monitoring: Watch CPU/memory usage during streaming
- Enable Debug Logging: Set
NODE_ENV=development - Hot Reload: Use
nodemonfor development - API Testing: Use Postman or curl for endpoint testing
- Docker Development: Use volume mounts for live code updates
This project is licensed under the MIT License - see the LICENSE file for details.
- ✅ Multi-platform music streaming (YouTube, JioSaavn, SoundCloud)
- ✅ Icecast server integration for professional broadcasting
- ✅ Dual streaming support (Icecast + direct HTTP)
- ✅ Real-time MP3 streaming with metadata support
- ✅ Dynamic queue management with priority support
- ✅ Smart caching system with LRU eviction
- ✅ Block list management for content filtering
- ✅ Token-based authentication system
- ✅ Admin panel with user management
- ✅ WebSocket integration for real-time updates
- ✅ Docker containerization support
- ✅ Default playlist rotation system
- ✅ Metadata enrichment via Spotify API
- ✅ Automatic fallback system
- ✅ RESTful API with comprehensive endpoints
- ✅ Configurable settings management
- ✅ Comprehensive logging system
- 🔄 Web UI dashboard for easy management
- 🔄 Playlist import/export functionality
- 🔄 User favorites and personal playlists
- 🔄 Advanced analytics and reporting
- 🔄 Mobile app support
- 🔄 Social features (voting, requests)
- 🔄 Enhanced audio quality options
- 🔄 Multi-room audio support
We welcome contributions! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Install dependencies (
npm install) - Set up environment variables (
.envfile) - Run the development server (
npm start) - Make your changes and test thoroughly
- Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
- Follow the existing code style and patterns
- Add tests for new features
- Update documentation for any API changes
- Ensure Docker builds work correctly
- Test on multiple platforms when possible
- Music Platform APIs: Thanks to YouTube, JioSaavn, SoundCloud, and Spotify for their APIs
- Open Source Community: Various dependencies and tools that make this project possible
- FFmpeg Team: For the excellent audio processing capabilities
- Node.js Ecosystem: Express, Socket.IO, and other fantastic libraries
- Docker Community: For containerization best practices
If you find this project useful, please consider:
- ⭐️ Starring the repository on GitHub
- 🐛 Reporting issues and bugs
- 💡 Suggesting features and improvements
- 🤝 Contributing code or documentation
- 📢 Sharing the project with others
- 📚 Documentation: Read this README and API docs
- 🐛 Issues: GitHub Issues
- 💬 Discussions: GitHub Discussions
- 📧 Contact: Reach out via GitHub profile
Made with ❤️ by GauravGhost