π΅ A modern, Spotify-inspired music streaming application that searches and streams high-quality FLAC audio files from Telegram channels.
- π― Spotify-Inspired Design: Modern dark theme with professional layout
- π± Fully Responsive: Mobile-first design that works on all devices
- π Glass Morphism Effects: Beautiful translucent UI elements
- π Smooth Animations: Professional loading states and transitions
- π±οΈ Touch Optimized: Gesture support and touch-friendly controls
- π Smart Search: Intelligent search for FLAC audio files in Telegram channels
- β‘ Instant Streaming: Zero-wait playback with range request support
- οΏ½ Queue Management: Full queue system with shuffle and repeat modes
- ποΈ Professional Player: Complete audio controls with seek, volume, and progress
- π Background Playback: Continues playing when app loses focus
- ποΈ Media Session API: System media controls and lock screen integration
- πΎ Installable: Install as native app on mobile and desktop
- π Offline Support: Service worker with intelligent caching
- π Push Notifications: Background sync and updates
- π² App-like Experience: Full-screen mode and native feel
- π Fast Streaming: Direct Telegram streaming without full downloads
- π§ Smart Preloading: Background loading of next tracks for seamless playback
- πΎ Intelligent Caching: Concurrent downloads with background optimization
- π Real-time Metrics: Health monitoring and performance tracking
- οΏ½ Range Requests: HTTP range support for instant playback
- π‘οΈ Official Telegram API: Uses Pyrogram with proper authentication
- π Session Management: Secure credential handling
- π CORS Support: Proper API security and access control
- Backend: FastAPI (Python)
- Telegram API: Pyrogram
- Frontend: HTML5 + CSS3 + JavaScript + Howler.js
- Audio Streaming: Real-time FLAC streaming
- Templating: Jinja2
- Python 3.8+ installed on your system
- Telegram API credentials from my.telegram.org
- Access to a Telegram channel containing
.flacfiles
# Install Python dependencies
pip install -r requirements.txt-
Copy the example environment file:
cp .env.example .env
-
Edit
.envand fill in your credentials:# Get these from https://my.telegram.org/apps TG_API_ID=your_api_id_here TG_API_HASH=your_api_hash_here # Session name (creates a .session file) SESSION_NAME=paisong_session # Target channel (username like @channel or channel ID) TG_CHANNEL=@your_channel_here # Cache directory for downloaded files CACHE_DIR=./cache
- Go to my.telegram.org
- Log in with your phone number
- Create a new application
- Copy your
API IDandAPI Hash - Add these to your
.envfile
# Start the FastAPI server
uvicorn server:app --reloadThe application will be available at: http://localhost:8000
- Open http://localhost:8000 in your browser
- Enter your search query in the search box
- Click "SEARCH" to find
.flacfiles - Click "PLAY" on any result to load the audio player
- Use the audio controls to play, pause, seek, and adjust volume
GET /search?query=your_search_term&limit=50Response:
{
"query": "your_search_term",
"results": [
{
"id": 12345,
"filename": "song.flac",
"text": "Description text",
"date": "2024-01-15T10:30:00",
"file_size": 45678912,
"duration": 245,
"stream_url": "/stream/12345"
}
],
"total": 1
}GET /stream/{message_id}Returns a streamable FLAC audio file.
GET /healthResponse:
{
"status": "healthy",
"telegram_client": "connected",
"cache_dir": "./cache",
"cached_files": 5
}| Variable | Description | Example |
|---|---|---|
TG_API_ID |
Telegram API ID | 12345678 |
TG_API_HASH |
Telegram API Hash | abcdef1234567890 |
SESSION_NAME |
Session file name | paisong_session |
TG_CHANNEL |
Target channel | @musicchannel |
CACHE_DIR |
Cache directory path | ./cache |
| Parameter | Type | Default | Description |
|---|---|---|---|
query |
string | required | Search term |
limit |
integer | 50 | Max results to return |
PaiSong/
βββ server.py # FastAPI server with Pyrogram
βββ requirements.txt # Python dependencies
βββ .env.example # Environment variables template
βββ .env # Your actual environment variables (create this)
βββ README.md # This file
βββ templates/
β βββ index.html # Frontend HTML template
βββ cache/ # Downloaded files cache (auto-created)
βββ *.session # Telegram session files (auto-created)
# With auto-reload
uvicorn server:app --reload --host 0.0.0.0 --port 8000
# With custom port
uvicorn server:app --reload --port 8080Set environment variable for detailed logging:
export PYTHONPATH=.
uvicorn server:app --reload --log-level debug-
"Telegram client not initialized"
- Check your
TG_API_IDandTG_API_HASHin.env - Make sure the session file has proper permissions
- Try deleting the
.sessionfile and restart
- Check your
-
"Audio message not found"
- Verify the channel name/ID is correct
- Ensure you have access to the channel
- Check if the message still exists
-
"Failed to download file"
- Check internet connection
- Verify cache directory permissions
- Ensure sufficient disk space
-
Audio won't play
- Check browser console for errors
- Try a different browser (Chrome/Firefox recommended)
- Verify the file is actually a valid FLAC file
- Cache Management: Cached files help performance but can consume disk space
- Search Limits: Use reasonable search limits to avoid timeouts
- Channel Size: Large channels may take longer to search
- Keep your
.envfile secure - never commit it to version control - API credentials are sensitive - don't share them
- Session files contain authentication data - keep them private
- The app only accesses public channel content you have access to
This project is for educational and personal use. Make sure you comply with Telegram's Terms of Service when using their API.
Enjoy discovering and streaming your favorite FLAC audio files! π΅