Go to file
Norbert Varga f2c9c4e388
Merge pull request #14 from pmezhuev/patch-2
Fix "not an url" for groups
2024-08-16 07:52:23 +03:00
.vscode Init 2023-08-14 14:56:49 +02:00
.gitignore Add run script 2023-08-14 15:52:02 +02:00
cmd.go Init 2023-08-14 14:56:49 +02:00
config.inc.sh-example Add max. file size limit handling 2023-08-15 10:06:07 +02:00
convert.go Add audio only download support 2023-09-08 17:08:44 +02:00
demo.gif Replace screenshot with a demo animation 2023-08-14 22:39:12 +02:00
dl.go Add audio only download support 2023-09-08 17:08:44 +02:00
docker-build.sh Add network to use in the docker image 2023-08-16 16:45:51 +02:00
docker-push.sh Add docker push script 2023-08-15 10:09:09 +02:00
Dockerfile Fix go version in Dockerfile 2024-08-13 21:44:12 +03:00
go.mod Upgrade go and modules 2024-06-26 09:13:35 +02:00
go.sum Upgrade go and modules 2024-06-26 09:13:35 +02:00
helper.go Init 2023-08-14 14:56:49 +02:00
LICENSE Init 2023-08-14 14:56:49 +02:00
main.go Fix "not an url" for groups 2024-08-14 00:48:40 +03:00
params.go Auto download yt-dlp if not found in path 2023-10-01 11:32:22 +02:00
queue.go Add audio only download support 2023-09-08 17:08:44 +02:00
README.md Add audio only download support 2023-09-08 17:08:44 +02:00
rereader.go Init 2023-08-14 14:56:49 +02:00
run.sh Auto download yt-dlp if not found in path 2023-10-01 11:32:22 +02:00
upload.go Add audio only download support 2023-09-08 17:08:44 +02:00
vercheck.go Auto update yt-dlp 2023-10-01 11:41:15 +02:00
yt-dlp-telegram-bot.code-workspace Init 2023-08-14 14:56:49 +02:00
yt-dlp.conf Add cookie support in docker image 2023-08-14 21:58:25 +02:00

yt-dlp-telegram-bot

This bot downloads videos from various supported sources (see yt-dlp) and then re-uploads them to Telegram, so they can be viewed with Telegram's built-in video player.

The bot displays the progress and further information during processing by responding to the message with the URL. Requests are queued, only one gets processed at a time.

The bot uses the Telegram MTProto API, which supports larger video uploads than the default 50MB with the standard Telegram bot API. Videos are not saved on disk. Incompatible video and audio streams are automatically converted to match those which are supported by Telegram's built-in video player.

The only dependencies are yt-dlp and ffmpeg. Tested on Linux, but should be able to run on other operating systems.

Compiling

You'll need Go installed on your computer. Install a recent package of golang. Then:

go get github.com/nonoo/yt-dlp-telegram-bot
go install github.com/nonoo/yt-dlp-telegram-bot

This will typically install yt-dlp-telegram-bot into $HOME/go/bin.

Or just enter go build in the cloned Git source repo directory.

Prerequisites

  1. Create a Telegram bot using BotFather and get the bot's token.
  2. Get your Telegram API Keys (api_id and api_hash). You'll need to create an app if you haven't created one already. Description is optional, set the category to "other". If an error dialog pops up, then try creating the app using your phone's browser.
  3. Make sure yt-dlp, ffprobe and ffmpeg commands are available on your system.

Running

You can get the available command line arguments with -h. Mandatory arguments are:

  • -api-id: set this to your Telegram app api_id
  • -api-hash: set this to your Telegram app api_hash
  • -bot-token: set this to your Telegram bot's token

Set your Telegram user ID as an admin with the -admin-user-ids argument. Admins will get a message when the bot starts and when a newer version of yt-dlp is available (checked every 24 hours).

Other user/group IDs can be set with the -allowed-user-ids and -allowed-group-ids arguments. IDs should be separated by commas.

You can get Telegram user IDs by writing a message to the bot and checking the app's log, as it logs all incoming messages.

You can set a max. upload file size limit with the -max-size argument. Example: -max-size 512MB

All command line arguments can be set through OS environment variables. Note that using a command line argument overwrites a setting by the environment variable. Available OS environment variables are:

  • API_ID
  • API_HASH
  • BOT_TOKEN
  • YTDLP_PATH
  • ALLOWED_USERIDS
  • ADMIN_USERIDS
  • ALLOWED_GROUPIDS
  • MAX_SIZE
  • YTDLP_COOKIES

The contents of the YTDLP_COOKIES environment variable will be written to the file /tmp/ytdlp-cookies.txt. This will be used by yt-dlp if it is running in a docker container, as the yt-dlp.conf file in the container points to this cookie file.

Supported commands

  • /dlp - Download given URL. If the first attribute is "mp3" then only the audio stream will be downloaded and converted (if needed) to 320k MP3
  • /dlpcancel - Cancel ongoing download

You don't need to enter the /dlp command if you send an URL to the bot using a private chat.

Contributors

Donations

If you find this bot useful then buy me a beer. :)