Spotigram is a high-speed, asynchronous Telegram bot that acts as a direct bridge between Spotify and Telegram. Built with a sleek, minimalist terminal-style UI, it allows users to download Spotify Tracks, Albums, and Playlists in original high-quality audio directly within Telegram.
Created by Ankit Roy
- High-Speed MTProto Uploads: Uses Pyrogram to upload files up to 2GB natively, bypassing standard HTTP bot API limits.
- Parallel Playlist Processing: Uses a bounded
asyncio.Queueand worker pool to process playlists with backpressure, keeping temporary files under control. - Persistent Rate Limiting: Integrated MongoDB database tracks users and enforces a strict 30-second cooldown shield to prevent spam and server overload.
- Custom Terminal UI: Features a highly stylized, dark-mode terminal aesthetic for all bot responses and live-updating progress bars.
- Smart Metadata Extraction: Automatically fetches high-res album art and cleans up artist tags (max 2 artists) for beautiful Telegram audio descriptions.
- Zero-Bandwidth Logging: Instantly clones delivered tracks to a private log channel using native Telegram message copying, saving server bandwidth.
- Tunable Backpressure: Queue depth, worker count, and audio concurrency can be tuned with environment variables for safer multi-user load.
Before you start, you will need:
- Python 3.9 or higher installed on your machine.
- A Telegram Bot Token (from @BotFather).
- A Telegram API ID and Hash (from my.telegram.org).
- A MongoDB Cloud URI (Free M0 Cluster from MongoDB Atlas).
1. Clone the repository
git clone https://github.com/ankittroy-21/Spotigram.git
cd Spotigram2. Create and activate a Virtual Environment
- Windows:
python -m venv venv
.\venv\Scripts\activate- Mac/Linux:
python3 -m venv venv
source venv/bin/activate3. Install dependencies
pip install -r requirements.txt4. Configure Environment Variables
Rename the .env.example file to .env (or create a new .env file) and fill in your credentials:
- To Create a .env from the .env.example:
cp .env.example .env- Your .env file will look like this:
API_ID=12345678
API_HASH=your_api_hash_here
BOT_TOKEN=your_bot_token_here
MONGO_URI=mongodb+srv://<username>:<password>@cluster0.abcde.mongodb.net/?retryWrites=true&w=majority
DB_NAME=spotigram_db
LOG_CHANNEL=-1001234567890
BOT_USERNAME=YourSpotigramBot
TRACK_QUEUE_SIZE=12
TRACK_QUEUE_WORKERS=2
GLOBAL_AUDIO_CONCURRENCY=3
TRACK_QUEUE_SIZE, TRACK_QUEUE_WORKERS, and GLOBAL_AUDIO_CONCURRENCY control how much work Spotigram will queue under load before it starts applying backpressure.
Defaults are TRACK_QUEUE_SIZE=12, TRACK_QUEUE_WORKERS=2, and GLOBAL_AUDIO_CONCURRENCY=3. For small deployments, keep the queue size low and raise it only if you have enough CPU, memory, and disk headroom to absorb bursts safely.
How to get your Environment Variables:
-
API_ID & API_HASH: Go to
my.telegram.org, log in, click "API development tools", and create an app to get these numbers. -
BOT_TOKEN: Message
@BotFatheron Telegram, use /newbot, and copy the HTTP API Token. -
MONGO_URI:
Go to MongoDB Atlas and create a free M0 cluster.
Create a Database User and password (do not use @, :, or / in the password).
Click "Connect" -> "Drivers" -> "Python" and copy the connection string. Replace <password> with your actual password.
-
LOG_CHANNEL: Create a private Telegram channel, add your bot as an admin, and forward a message from that channel to
@JsonDumpBotto find the channel ID (it will start with -100). -
BOT_USERNAME: The exact username of your bot without the
@symbol (used for custom branding).
Once your .env is configured, start the engine:
python main.pyIf successful, your terminal will display:
° Spotigram is now running. Waiting for messages...Go to Telegram, press /start, and drop a Spotify link!
Spotigram/
├── core/
│ ├── __init__.py
│ └── scraper.py # DRM bypass, data parsing, and queue-backed download engine
├── main.py # Pyrogram controller, event loop, and custom UI
├── database.py # MongoDB Motor client and rate-limiting logic
├── config.py # Environment variable loader
├── requirements.txt # Dependency list
└── README.md
This bot acts as a wrapper for third-party web scraping APIs. It is built strictly for educational purposes and personal archiving. Users are responsible for adhering to Spotify's Terms of Service and local copyright laws regarding the distribution of DRM-protected content.