File size: 6,873 Bytes
cb5acd8 bbe872c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 |
---
title: Reclip Telegram Bot
emoji: π₯
colorFrom: blue
colorTo: indigo
sdk: docker
pinned: false
---
# ReClip Telegram Bot
A self-hosted Telegram bot that downloads media from YouTube, TikTok, Instagram, Twitter, Reddit, and 1000+ other sites. Powered by [reclip](https://github.com/averygan/reclip) and yt-dlp.
Send a link, pick your format and quality, get the file delivered right in the chat.

## Features
- Multi-platform support (YouTube, TikTok, Instagram, Twitter, Reddit, and 1000+ more via yt-dlp)
- Format selection (MP4 video or MP3 audio)
- Quality picker with all available resolutions
- Real-time download progress (percentage)
- Thumbnail preview with metadata (title, platform, duration)
- Files up to 2GB via self-hosted Telegram Bot API
- Automatic file cleanup (configurable age and disk limits)
- Concurrent download limiting (prevents resource exhaustion)
- Admin dashboard with download stats, history, error tracking, and disk management
- Web UI included (reclip's built-in web interface)

## Architecture
```
Telegram User ββ> Self-hosted Bot API (2GB limit)
β
βΌ
bot (python-telegram-bot + httpx)
β β
HTTP β β HTTP events
βΌ βΌ
reclip (Flask) dashboard (FastAPI)
port 8899 port 8080
β
βΌ
SQLite
```
Four Docker containers via docker-compose:
1. **reclip** - Media download engine with REST API and web UI
2. **bot** - Telegram bot that wraps reclip's API
3. **telegram-bot-api** - Self-hosted Telegram Bot API server for 2GB upload limit
4. **dashboard** - Admin panel with download stats, history, errors, and file management
## Quick Start
### Prerequisites
- Docker and Docker Compose
- A Telegram bot token (from [@BotFather](https://t.me/BotFather))
- Telegram API credentials (from [my.telegram.org](https://my.telegram.org))
### Setup
1. Clone this repository:
```bash
git clone https://github.com/gth-ai/reclip-telegram-bot.git
cd reclip_bot
```
2. Copy the example environment file:
```bash
cp .env.example .env
```
3. Edit `.env` with your credentials:
```bash
BOT_TOKEN=your-bot-token-from-botfather
TELEGRAM_API_ID=your-api-id
TELEGRAM_API_HASH=your-api-hash
```
To get Telegram API credentials:
- Go to https://my.telegram.org
- Log in with your phone number
- Go to "API Development Tools"
- Create a new application (any name/description works)
- Copy the `api_id` and `api_hash`
4. Start the services:
```bash
docker-compose up -d
```
5. Send a video link to your bot on Telegram.
### First Run Note
The self-hosted Bot API server downloads some data from Telegram on first startup. This can take a minute. The bot will start responding once the Bot API server is ready.
## Configuration
All configuration is via environment variables in `.env`:
| Variable | Default | Description |
|---|---|---|
| `BOT_TOKEN` | (required) | Telegram bot token from @BotFather |
| `TELEGRAM_API_ID` | (required) | Telegram API ID from my.telegram.org |
| `TELEGRAM_API_HASH` | (required) | Telegram API hash from my.telegram.org |
| `MAX_CONCURRENT_DOWNLOADS` | 3 | Max parallel downloads |
| `CLEANUP_MAX_AGE_HOURS` | 1 | Delete files older than this |
| `CLEANUP_MAX_DISK_MB` | 5000 | Max disk usage before cleanup |
| `CLEANUP_INTERVAL_SECONDS` | 300 | Cleanup check interval |
| `DASHBOARD_USER` | admin | Dashboard login username |
| `DASHBOARD_PASSWORD` | (required) | Dashboard login password |
| `DASHBOARD_PORT` | 8080 | Dashboard port on host |
| `DASHBOARD_SECRET_KEY` | change-me | Cookie signing key |
## Admin Dashboard
The admin dashboard is available at http://localhost:8080 after starting the services. Log in with the credentials from your `.env` file.
Pages:
- **Dashboard** β downloads today, active users, disk usage, error rate, charts
- **History** β full download log with filters and pagination
- **Errors** β failed downloads with error messages
- **Admin** β file management, system info, purge controls
## Web UI
The reclip web UI is available if you uncomment the `reclip-web` service in `docker-compose.yml`:
```yaml
reclip-web:
extends:
service: reclip
ports:
- "8899:8899"
```
Then access it at http://localhost:8899.
## How It Works
1. You send a URL to the bot
2. Bot sends "Fetching info..." immediately
3. Bot calls reclip's API to get video metadata
4. Bot displays thumbnail, title, platform, and format buttons (MP4/MP3)
5. You tap MP4 to see quality options (1080p, 720p, etc.) or MP3 for audio
6. Bot starts the download and shows real-time progress
7. Bot uploads the file to the Telegram chat
8. Cleanup task removes old files automatically
## Development
### Running locally (without Docker)
```bash
# Start reclip
cd reclip && pip install flask yt-dlp && python app.py &
# Start the bot
cd bot && pip install -r requirements.txt
BOT_TOKEN=your-token RECLIP_URL=http://localhost:8899 DOWNLOADS_PATH=../reclip/downloads python bot.py
```
### Project structure
```
reclip_bot/
βββ docker-compose.yml # 4 services: reclip, bot, telegram-bot-api, dashboard
βββ .env.example # Environment variables template
βββ bot/
β βββ bot.py # Bot entry point
β βββ handlers.py # Telegram message/callback handlers
β βββ reclip_client.py # Async HTTP client for reclip API
β βββ event_client.py # Fire-and-forget events to dashboard
β βββ cleanup.py # Background file cleanup task
β βββ requirements.txt
β βββ Dockerfile
βββ dashboard/
β βββ main.py # FastAPI app with background tasks
β βββ db.py # SQLite queries (async via aiosqlite)
β βββ auth.py # Session cookie auth
β βββ routes/ # API + page routes
β βββ templates/ # Jinja2 templates (dark theme)
β βββ static/ # CSS + Chart.js frontend
β βββ requirements.txt
β βββ Dockerfile
βββ reclip/ # Fork of averygan/reclip with enhancements
βββ app.py # Flask API + web UI (with progress hooks)
βββ Dockerfile
βββ templates/
βββ static/
```
## Credits
- [reclip](https://github.com/averygan/reclip) by averygan - The media download engine
- [yt-dlp](https://github.com/yt-dlp/yt-dlp) - The download backend
- [python-telegram-bot](https://github.com/python-telegram-bot/python-telegram-bot) - Telegram bot framework
## License
MIT
|