Download videos from Youtube and other platforms through a Telegram Bot
Find a file
Sanuja Seneviratne 2b6fb38c5c
Update README.md (Improve) (#315)
Improve "Run natively on your machine" guide
2023-12-05 18:36:53 +01:00
.github drop armv7 2023-11-15 17:27:26 +01:00
assets support instagram 2023-04-16 14:27:24 +02:00
conf add id to low script 2023-10-29 11:14:33 +01:00
k8s Add K8S Deloyment and Readme 2022-12-03 20:52:37 +01:00
scripts add id to low script 2023-10-29 11:14:33 +01:00
ytdlbot double default limits 2023-11-17 21:56:46 +01:00
.dockerignore add upgrade actions, add Makefile 2022-01-03 12:05:32 +08:00
.gitignore use session 2023-04-15 19:59:02 +02:00
.gitmodules remove submodule for better support of heroku 2021-05-24 09:27:49 +08:00
.gitpod.yml fix: exclude vp09 for download (#267) 2023-07-09 15:21:23 +02:00
apk.txt feat: add aria2 (#211) 2023-03-04 19:08:02 +01:00
app.json Update app.json (#279) 2023-08-12 16:46:29 +02:00
docker-compose.yml Pyrogram2 (#291) 2023-09-10 14:08:11 +02:00
Dockerfile Pyrogram2 (#291) 2023-09-10 14:08:11 +02:00
FAQ.md token mode instead of vip mode 2023-04-08 12:50:04 +02:00
k8s.md token mode instead of vip mode 2023-04-08 12:50:04 +02:00
LICENSE Initial commit 2021-05-03 18:24:44 +08:00
Makefile hot patch container 2022-02-02 15:15:52 +08:00
Procfile update README.md, fix heroku 2022-01-02 22:27:34 +08:00
README.md Update README.md (Improve) (#315) 2023-12-05 18:36:53 +01:00
requirements.txt Bump yt-dlp from 2023.11.14 to 2023.11.16 (#310) 2023-11-16 09:09:13 +01:00
worker.yml Pyrogram2 (#291) 2023-09-10 14:08:11 +02:00

ytdlbot

docker image

YouTube Download Bot🚀

This Telegram bot allows you to download videos from YouTube and other supported platforms, including Instagram!


READ FAQ FIRST IF YOU ENCOUNTER ANY ISSUES.


Deploy to heroku

Deploy to Heroku

If you are having trouble deploying, you can fork the project to your personal account and deploy it from there.

Starting November 28, 2022, free Heroku Dynos, free Heroku Postgres, and free Heroku Data for Redis® plans will no longer be available. Heroku Announcement

Usage

https://t.me/benny_ytdlbot

Send link directly to the bot. Any Websites supported by youtube-dl will work to.

Limitations of my bot

Due to limitations on servers and bandwidth, there are some restrictions on this free service.

  • Each user is limited to 20 free downloads per 24-hour period
  • there is a maximum of three subscriptions allowed for YouTube channels.

If you need more downloads, you can purchase additional tokens. Additionally, you have the option of deploying your own bot. See below instructions.

Features

  1. fast download and upload.
  2. ads free
  3. support progress bar
  4. audio conversion
  5. playlist support
  6. payment support
  7. support different video resolutions
  8. support sending as file or streaming as video
  9. supports celery worker distribution - faster than before.
  10. subscriptions to YouTube Channels
  11. cache mechanism - download once for the same video.
  12. support instagram posts

Screenshots

Normal download

Instagram download

celery

How to deploy?

This bot can be deployed on any platform that supports Python.

Need help with deployment or exclusive features? I offer paid service - contact me at @BennyThink

Run natively on your machine

To deploy this bot, follow these steps:

  1. Install bot dependencies

    • Install Python 3.6 or a later version, FFmpeg.
    • Aria2 and add it to the PATH.
  2. Clone the code from the repository and cd into it.

    • git clone "https://github.com/tgbot-collection/ytdlbot.git
      
    • cd ytdlbot/
      
  3. Creating a virtual environment and installing required modules in Python.

    • python -m venv venv
      
    • source venv/bin/activate   #Linux
      #or
      .\venv\Scripts\activate   #Windows
      
    • pip install --upgrade pip
      
    • pip install -r requirements.txt
      
  4. Set the environment variables TOKEN, APP_ID, APP_HASH, and any others that you may need.

    • Change values in ytdlbot/config.py or
    • Use export APP_ID=111 APP_HASH=111 TOKEN=123
  5. Finally run the bot with

    • python ytdl_bot.py
      

Docker

This bot has a simple one-line code and some functions, such as VIP and ping, are disabled.

docker run -e APP_ID=111 -e APP_HASH=111 -e TOKEN=370FXI bennythink/ytdlbot

Complete deployment guide for docker-compose

  • contains every functionality
  • compatible with amd64, arm64 and armv7l

1. get docker-compose.yml

Download docker-compose.yml file to a directory

2. create data directory

mkdir data
mkdir env

3. configuration

3.1. set environment variables

vim env/ytdl.env

You can configure all the following environment variables:

  • WORKERS: workers count for celery
  • PYRO_WORKERS: number of workers for pyrogram, default is 100
  • APP_ID: REQUIRED, get it from https://core.telegram.org/
  • APP_HASH: REQUIRED
  • TOKEN: REQUIRED
  • REDIS: REQUIRED if you need VIP mode and cache ⚠️ Don't publish your redis server on the internet. ⚠️
  • EXPIRE: token expire time, default: 1 day
  • ENABLE_VIP: enable VIP mode
  • OWNER: owner username
  • AUTHORIZED_USER: only authorized users can use the bot
  • REQUIRED_MEMBERSHIP: group or channel username, user must join this group to use the bot
  • ENABLE_CELERY: celery mode, default: disable
  • ENABLE_QUEUE: celery queue
  • BROKER: celery broker, should be redis://redis:6379/0
  • MYSQL_HOST:MySQL host
  • MYSQL_USER: MySQL username
  • MYSQL_PASS: MySQL password
  • AUDIO_FORMAT: default audio format
  • ARCHIVE_ID: forward all downloads to this group/channel
  • IPv6 = os.getenv("IPv6", False)
  • ENABLE_FFMPEG = os.getenv("ENABLE_FFMPEG", False)
  • PROVIDER_TOKEN: stripe token on Telegram payment
  • PLAYLIST_SUPPORT: download playlist support
  • M3U8_SUPPORT: download m3u8 files support
  • ENABLE_ARIA2: enable aria2c download
  • FREE_DOWNLOAD: free download count per day
  • TOKEN_PRICE: token price per 1 USD
  • GOOGLE_API_KEY: YouTube API key, required for YouTube video subscription.
  • RCLONE_PATH: rclone path to upload files to cloud storage
  • TMPFILE_PATH: tmpfile path(file download path)

3.2 Set up init data

If you only need basic functionality, you can skip this step.

3.2.1 Create MySQL db

Required for VIP, settings, YouTube subscription.

docker-compose up -d
docker-compose exec mysql bash

mysql -u root -p

> create database ytdl;

3.2.2 Setup flower db in ytdlbot/ytdlbot/data

Required if you enable celery and want to monitor the workers.

{} ~ python3
Python 3.9.9 (main, Nov 21 2021, 03:22:47)
[Clang 12.0.0 (clang-1200.0.32.29)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import dbm;dbm.open("flower","n");exit()

3.2.3 Setup instagram cookies

You don't need to do this anymore! This bot support instagram posts out of the box, including photos, videos and reels.

3.3 Tidy docker-compose.yml

In flower service section, you may want to change your basic authentication username password and publish port.

You can also limit CPU and RAM usage by adding a `deploy' key:

    deploy:
      resources:
        limits:
          cpus: '0.5'
          memory: 1500M

Be sure to use --compatibility when deploying.

4. run

4.1. standalone mode

If you only want to run the mode without any celery worker and VIP mode, you can just start ytdl service

docker-compose up -d ytdl

4.2 VIP mode

You'll have to start MySQL and redis to support VIP mode, subscription and settings.

docker-compose up -d mysql redis ytdl

4.3 Celery worker mode

Firstly, set ENABLE_CELERY to true. And then, on one machine:

docker-compose up -d

On the other machine:

docker-compose -f worker.yml up -d

⚠️ Please bear in mind that you should not publish Redis directly on the internet. Instead, you can use WireGuard to wrap it up for added security.

kubernetes

refer guide here kubernetes

Command

start - Let's start
about - What's this bot?
ping - Bot running status
help - Help
ytdl - Download video in group
settings - Set your preference
buy - Buy token
direct - Download file directly
sub - Subscribe to YouTube Channel
unsub - Unsubscribe from YouTube Channel
sub_count - Check subscription status, owner only.
uncache - Delete cache for this link, owner only.
purge - Delete all tasks, owner only.

Test data

Test video

https://www.youtube.com/watch?v=BaW_jenozKc

Test Playlist

https://www.youtube.com/playlist?list=PL1Hdq7xjQCJxQnGc05gS4wzHWccvEJy0w

Test twitter

https://twitter.com/nitori_sayaka/status/1526199729864200192 https://twitter.com/BennyThinks/status/1475836588542341124

Test instagram

https://www.instagram.com/p/ClBSqo3PkJw/

https://www.instagram.com/p/CaiAHoWDnrM/

https://www.instagram.com/p/CZtUDyyv1u1/

Donation

Stripe

You can choose to donate via Stripe by clicking the button below.

Select the currency and payment method that suits you.

USD(Card, Apple Pay and Google Pay) SEK(Card, Apple Pay and Google Pay) CNY(Card, Apple Pay, Google Pay and Alipay)
USD SEK CNY

License

Apache License 2.0