Telegram bot for extracting audio from YouTube videos.
- Extract audio from YouTube videos
- Best quality audio format
- Direct streaming to Telegram (no disk storage)
- Link validation and video availability check
- Concurrent request protection per user
- Optional proxy support (residential recommended)
- Clean Architecture with full TypeScript typing
- TypeScript - Full type safety
- Grammy - Modern Telegram bot framework
- Fastify - HTTP health check server
- Pino - Structured logging
- yt-dlp - Audio extraction
- Zod - Runtime validation
- Biome - Linting and formatting
- Node.js >= 20
- Docker (optional, for deployment)
- Telegram Bot Token (get from @BotFather)
# Install dependencies
npm install
# Install yt-dlp and ffmpeg
brew install yt-dlp ffmpeg # macOS
# or
sudo apt install ffmpeg && pip install yt-dlp # Linux
# Create .env file
cp .env.example .env
# Add your BOT_TOKEN to .env
# Run in development mode
npm run dev# Using Docker Compose
docker compose up -d
# View logs
docker compose logs -f# Required
BOT_TOKEN=your_bot_token_here
# Optional
PORT=3000
NODE_ENV=production
LOG_LEVEL=info
PROXY_URL=socks5://user:pass@host:port # Residential proxy recommended
YOUTUBE_COOKIES=... # For age-restricted content
YOUTUBE_PO_TOKEN=... # For bypassing bot detectionFor reliable YouTube access, especially from cloud/datacenter IPs, use a residential proxy:
- Bright Data - https://brightdata.com
- Smartproxy - https://smartproxy.com
- Oxylabs - https://oxylabs.io
- Proxy6 - https://proxy6.net
Format: socks5://user:pass@host:port or http://user:pass@host:port
- Create account on Render.com
- Connect your GitHub repository
- Render will auto-detect
render.yaml - Add
BOT_TOKENin environment variables - Deploy!
src/
├── domain/ # Business logic
│ ├── entities/ # AudioRequest, AudioFile
│ └── interfaces/ # IAudioExtractor, ILogger
├── application/ # Use cases
│ └── usecases/ # ProcessAudioRequest
├── infrastructure/ # External dependencies
│ ├── telegram/ # Grammy bot wrapper
│ ├── youtube/ # yt-dlp wrapper
│ └── http/ # Fastify server, Pino logger
├── presentation/ # Message handlers
│ └── telegram/ # Telegram handlers
├── config/ # Configuration
└── index.ts # Entry point
- Find the bot in Telegram
- Send
/start - Send a YouTube link
- Receive the audio file
https://youtube.com/watch?v=...https://youtu.be/...https://youtube.com/shorts/...
- Public videos only (cookies needed for age-restricted)
- Cloud/datacenter IPs may be blocked by YouTube (use residential proxy)
npm run dev # Development mode with hot reload
npm run build # Compile TypeScript
npm run start # Run production build
npm run lint # Check linting
npm run lint:fix # Auto-fix linting issues
npm run format # Format codeISC