A Telegram bot that downloads audio from YouTube and delivers it straight to your chat.
TelegramBotYTMusicLoader is a self-hosted Telegram bot built on .NET 10 that lets you send a YouTube link (or a search query) and get back an audio track, ready to listen to right inside Telegram — no ads, no extra apps, no manual conversion.
Under the hood it relies on the battle-tested yt-dlp for extraction and ffmpeg for audio processing, wrapped in a clean .NET application and shipped as a ready-to-run Docker image.
- 🔗 Link → Audio — send a YouTube video or playlist link and receive an MP3 in return
- ⚙️ Powered by yt-dlp & ffmpeg — reliable extraction and high-quality audio conversion
- 🍪 Cookie support — use
cookies.txtto access age-restricted or region-locked content - 🗄️ EF Core data layer — persistent storage via Entity Framework Core (
dotnet-eftooling included) - 🐳 Docker-first — a single
Dockerfilebuilds and runs the whole bot, dependencies included - 🧩 .NET 10 solution — clean, modern C# codebase (
TelegramBotYtMusic.sln)
| Component | Purpose |
|---|---|
| .NET 10 (C#) | Core application / bot logic |
| Telegram Bot API | Chat interface |
| yt-dlp (Python) | Fetching audio/video from YouTube |
| ffmpeg | Audio extraction & conversion |
| Entity Framework Core | Data persistence |
| Docker | Packaging & deployment |
- Docker (recommended), or
- .NET 10 SDK +
ffmpeg+yt-dlp+ Python 3 installed locally - A Telegram bot token from @BotFather
# Clone the repository
git clone https://github.com/DmitryMagich/TelegramBotYTMusicLoader.git
cd TelegramBotYTMusicLoader
# Build the image
docker build -t telegram-yt-music-bot .
# Run the container
docker run -d \
--name yt-music-bot \
-e TELEGRAM_BOT_TOKEN="your_bot_token_here" \
-v $(pwd)/Downloads:/app/Downloads \
telegram-yt-music-bot
⚠️ Checkappsettings.jsoninsideTelegramBotYtMusic/for the exact configuration keys expected by your build (bot token, database connection string, etc.) — adjust environment variables accordingly.
git clone https://github.com/DmitryMagich/TelegramBotYTMusicLoader.git
cd TelegramBotYTMusicLoader
# Restore & build
dotnet restore
dotnet build
# Apply EF Core migrations, if any
dotnet tool restore
dotnet ef database update --project TelegramBotYtMusic
# Run
dotnet run --project TelegramBotYtMusicMake sure ffmpeg, python3, and yt-dlp (pip install yt-dlp) are available on your PATH.
Some YouTube videos require authentication (age-restricted or region-locked content). Export your browser cookies in Netscape format into cookies.txt and place it at the project root — the bot automatically picks it up and forwards it to yt-dlp.
- Start a chat with your bot on Telegram.
- Send a YouTube link (video or playlist).
- Wait while the bot downloads and converts the audio.
- Receive the ready-to-play audio file directly in chat.
TelegramBotYTMusicLoader/
├── TelegramBotYtMusic/ # Main application source code
├── TelegramBotYtMusic.sln # .NET solution file
├── Dockerfile # Container build definition
├── dotnet-tools.json # Local .NET tools (dotnet-ef)
├── cookies.txt # Optional yt-dlp auth cookies
└── .gitignore
Contributions, issues, and feature requests are welcome! Feel free to open a pull request or issue.