2021-08-29 10:19:49 +08:00
|
|
|
# ytdlbot
|
|
|
|
|
2022-01-02 21:49:03 +08:00
|
|
|
[](https://github.com/tgbot-collection/ytdlbot/actions/workflows/builder.yaml)
|
|
|
|
|
2021-08-30 22:06:32 +08:00
|
|
|
YouTube Download Bot🚀
|
2021-08-29 10:19:49 +08:00
|
|
|
|
2023-04-07 04:33:24 +08:00
|
|
|
This Telegram bot allows you to download videos from YouTube and other supported platforms.
|
2021-05-04 12:01:53 +08:00
|
|
|
|
2022-01-02 21:49:03 +08:00
|
|
|
-----
|
2022-09-05 18:22:21 +08:00
|
|
|
**READ [FAQ](FAQ.md) FIRST IF YOU ENCOUNTER ANY ISSUES.**
|
2022-01-02 21:49:03 +08:00
|
|
|
|
2022-09-05 18:22:21 +08:00
|
|
|
-----
|
2021-05-23 22:25:15 +08:00
|
|
|
[](https://heroku.com/deploy)
|
2021-05-04 12:01:53 +08:00
|
|
|
|
2023-04-07 04:33:24 +08:00
|
|
|
If you are having trouble deploying, you can fork the project to your personal account and deploy it from there.
|
2022-09-05 18:22:21 +08:00
|
|
|
|
|
|
|
**Starting November 28, 2022, free Heroku Dynos, free Heroku Postgres, and free Heroku Data for Redis® plans will no
|
|
|
|
longer be available.**
|
2022-08-26 23:11:39 +08:00
|
|
|
[Heroku Announcement](https://devcenter.heroku.com/articles/free-dyno-hours)
|
2022-01-02 21:49:03 +08:00
|
|
|
|
2021-08-29 10:19:49 +08:00
|
|
|
# Usage
|
2021-05-04 12:01:53 +08:00
|
|
|
|
|
|
|
[https://t.me/benny_ytdlbot](https://t.me/benny_ytdlbot)
|
|
|
|
|
2021-08-29 10:19:49 +08:00
|
|
|
Send link directly to the bot. Any
|
2022-01-02 21:49:03 +08:00
|
|
|
Websites [supported by youtube-dl](https://ytdl-org.github.io/youtube-dl/supportedsites.html) will also work.
|
2021-05-04 12:01:53 +08:00
|
|
|
|
2022-01-02 21:49:03 +08:00
|
|
|
# Limitations of my bot
|
2021-08-29 10:19:49 +08:00
|
|
|
|
2023-04-07 04:33:24 +08:00
|
|
|
Due to limitations on servers and bandwidth, there are some restrictions on this service.
|
2022-02-07 19:50:07 +08:00
|
|
|
|
2023-04-07 04:33:24 +08:00
|
|
|
* Each user is limited to 5 free downloads per 24-hour period
|
|
|
|
* there is a maximum of three subscriptions allowed for YouTube channels.
|
2021-08-29 10:19:49 +08:00
|
|
|
|
2023-04-07 04:33:24 +08:00
|
|
|
If you require more downloads, you can purchase additional tokens. Additionally, you have the option of deploying your
|
|
|
|
own bot.
|
2021-08-29 10:19:49 +08:00
|
|
|
|
|
|
|
# Features
|
|
|
|
|
|
|
|

|
2021-05-05 12:07:03 +08:00
|
|
|
|
2021-08-29 10:19:49 +08:00
|
|
|
1. fast download and upload.
|
|
|
|
2. ads free
|
|
|
|
3. support progress bar
|
|
|
|
4. audio conversion
|
|
|
|
5. playlist support
|
2023-04-07 04:33:24 +08:00
|
|
|
6. payment support
|
2021-12-07 21:32:06 +08:00
|
|
|
7. support different video resolutions
|
|
|
|
8. support sending as file or streaming as video
|
2022-01-02 21:49:03 +08:00
|
|
|
9. supports celery worker distribution - faster than before.
|
2022-02-04 12:25:10 +08:00
|
|
|
10. subscriptions to YouTube Channels
|
2022-04-19 03:28:20 +08:00
|
|
|
11. cache mechanism - download once for the same video.
|
2021-12-07 21:32:06 +08:00
|
|
|
|
2022-01-02 21:49:03 +08:00
|
|
|

|
2021-05-05 12:07:03 +08:00
|
|
|
|
2021-05-04 13:36:28 +08:00
|
|
|
# How to deploy?
|
2021-08-29 10:19:49 +08:00
|
|
|
|
2023-04-07 04:33:24 +08:00
|
|
|
This bot can be deployed on any platform that supports Python.
|
2021-08-30 22:42:54 +08:00
|
|
|
|
2022-01-02 21:49:03 +08:00
|
|
|
## Run natively on your machine
|
2021-08-29 10:19:49 +08:00
|
|
|
|
2023-04-07 04:33:24 +08:00
|
|
|
To deploy this bot, follow these steps:
|
|
|
|
|
|
|
|
1. Clone the code from the repository.
|
|
|
|
2. Install FFmpeg.
|
|
|
|
3. Install Python 3.6 or a later version.
|
|
|
|
4. Install Aria2 and add it to the PATH.
|
|
|
|
5. Install the required packages by running `pip3 install -r requirements.txt`.
|
|
|
|
6. Set the environment variables `TOKEN`, `APP_ID`, `APP_HASH`, and any others that you may need.
|
|
|
|
7. Run `python3 ytdl_bot.py`.
|
2021-05-05 12:07:03 +08:00
|
|
|
|
2022-01-02 21:49:03 +08:00
|
|
|
## Docker
|
2021-08-30 22:42:54 +08:00
|
|
|
|
2023-04-07 04:33:24 +08:00
|
|
|
This bot has a simple one-line code and some functions, such as VIP and ping, are disabled.
|
2021-08-30 22:42:54 +08:00
|
|
|
|
|
|
|
```shell
|
|
|
|
docker run -e APP_ID=111 -e APP_HASH=111 -e TOKEN=370FXI bennythink/ytdlbot
|
|
|
|
```
|
|
|
|
|
2022-01-02 21:49:03 +08:00
|
|
|
# Complete deployment guide for docker-compose
|
2021-08-29 10:19:49 +08:00
|
|
|
|
2022-01-02 21:49:03 +08:00
|
|
|
* contains every functionality
|
|
|
|
* compatible with amd64, arm64 and armv7l
|
2021-08-29 10:19:49 +08:00
|
|
|
|
2022-01-02 21:49:03 +08:00
|
|
|
## 1. get docker-compose.yml
|
2021-08-29 10:19:49 +08:00
|
|
|
|
2022-01-02 21:49:03 +08:00
|
|
|
Download `docker-compose.yml` file to a directory
|
2021-08-29 10:19:49 +08:00
|
|
|
|
2022-01-02 21:49:03 +08:00
|
|
|
## 2. create data directory
|
2021-08-29 10:19:49 +08:00
|
|
|
|
|
|
|
```shell
|
2022-01-02 21:49:03 +08:00
|
|
|
mkdir data
|
|
|
|
mkdir env
|
2021-08-29 10:19:49 +08:00
|
|
|
```
|
|
|
|
|
2022-01-02 21:49:03 +08:00
|
|
|
## 3. configuration
|
|
|
|
|
|
|
|
### 3.1. set environment variables
|
2021-08-29 10:19:49 +08:00
|
|
|
|
|
|
|
```shell
|
2022-01-02 21:49:03 +08:00
|
|
|
vim env/ytdl.env
|
2021-08-29 10:19:49 +08:00
|
|
|
```
|
|
|
|
|
2023-04-07 04:33:24 +08:00
|
|
|
You can configure all the following environment variables:
|
2021-12-07 21:32:06 +08:00
|
|
|
|
2022-03-10 21:46:02 +08:00
|
|
|
* WORKERS: workers count for celery
|
2023-04-07 04:33:24 +08:00
|
|
|
* PYRO_WORKERS: number of workers for pyrogram, default is 100
|
2022-02-07 19:50:07 +08:00
|
|
|
* APP_ID: **REQUIRED**, get it from https://core.telegram.org/
|
2021-08-29 10:19:49 +08:00
|
|
|
* APP_HASH: **REQUIRED**
|
|
|
|
* TOKEN: **REQUIRED**
|
2022-02-08 10:04:54 +08:00
|
|
|
* REDIS: **REQUIRED if you need VIP mode and cache** ⚠️ Don't publish your redis server on the internet. ⚠️
|
2023-04-07 04:33:24 +08:00
|
|
|
* EXPIRE: token expire time, default: 1 day
|
|
|
|
* ENABLE_VIP: enable VIP mode
|
2021-08-29 10:19:49 +08:00
|
|
|
* OWNER: owner username
|
2023-04-07 04:33:24 +08:00
|
|
|
* 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
|
|
|
|
* ENABLE_ARIA2: enable aria2c download
|
|
|
|
* FREE_DOWNLOAD: free download count per day
|
|
|
|
* TOKEN_PRICE: token price per 1 USD
|
2022-02-07 19:50:07 +08:00
|
|
|
* GOOGLE_API_KEY: YouTube API key, required for YouTube video subscription.
|
2022-01-02 21:49:03 +08:00
|
|
|
|
|
|
|
## 3.2 Set up init data
|
|
|
|
|
2022-02-07 19:50:07 +08:00
|
|
|
If you only need basic functionality, you can skip this step.
|
|
|
|
|
2022-01-02 21:49:03 +08:00
|
|
|
### 3.2.1 Create MySQL db
|
|
|
|
|
2022-02-08 10:04:54 +08:00
|
|
|
Required for VIP, settings, YouTube subscription.
|
2022-02-07 19:50:07 +08:00
|
|
|
|
2022-01-02 21:49:03 +08:00
|
|
|
```shell
|
|
|
|
docker-compose up -d
|
|
|
|
docker-compose exec mysql bash
|
|
|
|
|
|
|
|
mysql -u root -p
|
|
|
|
|
2022-02-07 19:50:07 +08:00
|
|
|
> create database ytdl;
|
2022-01-02 21:49:03 +08:00
|
|
|
```
|
|
|
|
|
|
|
|
### 3.2.2 Setup flower db in `ytdlbot/ytdlbot/data`
|
2021-08-29 10:19:49 +08:00
|
|
|
|
2022-02-07 19:50:07 +08:00
|
|
|
Required if you enable celery and want to monitor the workers.
|
|
|
|
|
2022-01-02 21:49:03 +08:00
|
|
|
```shell
|
|
|
|
{} ~ 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()
|
2021-08-29 10:19:49 +08:00
|
|
|
```
|
2022-01-02 21:49:03 +08:00
|
|
|
|
|
|
|
### 3.2.3 Setup instagram cookies
|
|
|
|
|
2022-02-07 19:50:07 +08:00
|
|
|
Required if you want to support instagram.
|
|
|
|
|
2022-01-02 21:49:03 +08:00
|
|
|
You can use this extension
|
|
|
|
[Get cookies.txt](https://chrome.google.com/webstore/detail/get-cookiestxt/bgaddhkoddajcdgocldbbfleckgcbcid)
|
|
|
|
to get instagram cookies
|
|
|
|
|
|
|
|
```shell
|
|
|
|
vim data/instagram.com_cookies.txt
|
|
|
|
# paste your cookies
|
|
|
|
```
|
|
|
|
|
|
|
|
## 3.3 Tidy docker-compose.yml
|
|
|
|
|
|
|
|
In `flower` service section, you may want to change your basic authentication username password and publish port.
|
|
|
|
|
2023-04-07 04:33:24 +08:00
|
|
|
You can also limit CPU and RAM usage by adding a `deploy' key:
|
2022-01-03 10:26:03 +08:00
|
|
|
|
|
|
|
```docker
|
|
|
|
deploy:
|
|
|
|
resources:
|
|
|
|
limits:
|
|
|
|
cpus: '0.5'
|
|
|
|
memory: 1500M
|
|
|
|
```
|
|
|
|
|
|
|
|
Be sure to use `--compatibility` when deploying.
|
|
|
|
|
2022-01-02 21:49:03 +08:00
|
|
|
## 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
|
|
|
|
|
|
|
|
```shell
|
|
|
|
docker-compose up -d ytdl
|
|
|
|
```
|
|
|
|
|
|
|
|
### 4.2 VIP mode
|
|
|
|
|
2022-02-07 19:50:07 +08:00
|
|
|
You'll have to start MySQL and redis to support VIP mode, subscription and settings.
|
2022-01-02 21:49:03 +08:00
|
|
|
|
|
|
|
```
|
|
|
|
docker-compose up -d mysql redis ytdl
|
|
|
|
```
|
|
|
|
|
|
|
|
### 4.3 Celery worker mode
|
|
|
|
|
|
|
|
Firstly, set `ENABLE_CELERY` to true. And then, on one machine:
|
|
|
|
|
|
|
|
```shell
|
2021-08-29 10:19:49 +08:00
|
|
|
docker-compose up -d
|
|
|
|
```
|
2021-05-04 12:01:53 +08:00
|
|
|
|
2022-01-02 21:49:03 +08:00
|
|
|
On the other machine:
|
|
|
|
|
|
|
|
```shell
|
2022-02-07 19:50:07 +08:00
|
|
|
docker-compose -f worker.yml up -d
|
2022-01-02 21:49:03 +08:00
|
|
|
```
|
|
|
|
|
2023-04-07 04:33:24 +08:00
|
|
|
**⚠️ 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.**
|
2023-01-07 00:06:26 +08:00
|
|
|
|
2023-04-07 04:33:24 +08:00
|
|
|
## kubernetes
|
2023-01-07 00:06:26 +08:00
|
|
|
|
2023-04-07 04:33:24 +08:00
|
|
|
refer guide here [kubernetes](k8s.md)
|
2022-11-25 15:09:56 +08:00
|
|
|
|
2021-05-05 14:10:08 +08:00
|
|
|
# Command
|
2021-08-29 10:19:49 +08:00
|
|
|
|
2022-06-26 12:27:08 +08:00
|
|
|
```
|
2021-08-16 19:45:36 +08:00
|
|
|
start - Let's start
|
2022-02-04 12:25:10 +08:00
|
|
|
about - What's this bot?
|
2021-08-16 19:45:36 +08:00
|
|
|
ping - Bot running status
|
2022-02-04 12:25:10 +08:00
|
|
|
help - Help
|
2021-08-16 19:45:36 +08:00
|
|
|
ytdl - Download video in group
|
2021-12-07 21:32:06 +08:00
|
|
|
settings - Set your preference
|
2023-04-08 18:06:15 +08:00
|
|
|
buy - Buy token
|
2022-01-20 21:01:58 +08:00
|
|
|
direct - Download file directly
|
2022-02-04 12:25:10 +08:00
|
|
|
sub - Subscribe to YouTube Channel
|
|
|
|
unsub - Unsubscribe from YouTube Channel
|
2022-02-09 13:47:44 +08:00
|
|
|
sub_count - Check subscription status, owner only.
|
2023-01-07 19:11:26 +08:00
|
|
|
uncache - Delete cache for this link, owner only.
|
2023-04-08 18:06:15 +08:00
|
|
|
purge - Delete all tasks, owner only.
|
2021-05-05 12:07:03 +08:00
|
|
|
```
|
2021-05-05 14:10:08 +08:00
|
|
|
|
2022-01-04 21:33:03 +08:00
|
|
|
# Test data
|
|
|
|
|
|
|
|
## Test video
|
2021-08-29 10:19:49 +08:00
|
|
|
|
2021-05-05 14:10:08 +08:00
|
|
|
https://www.youtube.com/watch?v=BaW_jenozKc
|
|
|
|
|
2022-01-04 21:33:03 +08:00
|
|
|
## Test Playlist
|
2021-08-29 10:19:49 +08:00
|
|
|
|
2021-08-24 19:56:13 +08:00
|
|
|
https://www.youtube.com/playlist?list=PL1Hdq7xjQCJxQnGc05gS4wzHWccvEJy0w
|
|
|
|
|
2022-01-04 21:33:03 +08:00
|
|
|
## Test m3u8
|
|
|
|
|
|
|
|
https://dmesg.app/m3u8/prog_index.m3u8
|
|
|
|
|
2022-04-19 03:28:20 +08:00
|
|
|
## test twitter
|
2022-09-05 18:22:21 +08:00
|
|
|
|
2022-04-19 03:28:20 +08:00
|
|
|
https://twitter.com/nitori_sayaka/status/1526199729864200192
|
|
|
|
https://twitter.com/BennyThinks/status/1475836588542341124
|
|
|
|
|
2022-01-02 21:49:03 +08:00
|
|
|
# Donation
|
|
|
|
|
|
|
|
* [Buy me a coffee](https://www.buymeacoffee.com/bennythink)
|
|
|
|
* [Afdian](https://afdian.net/@BennyThink)
|
2023-01-07 00:06:26 +08:00
|
|
|
* [GitHub Sponsor](https://github.com/sponsors/BennyThink)
|
|
|
|
|
|
|
|
## Stripe
|
|
|
|
|
2023-04-07 04:33:24 +08:00
|
|
|
You can choose to donate via Stripe by clicking the button below.
|
|
|
|
|
|
|
|
Select the currency and payment method that suits you.
|
2023-01-07 00:06:26 +08:00
|
|
|
|
|
|
|
| USD(Card, Apple Pay and Google Pay) | SEK(Card, Apple Pay and Google Pay) | CNY(Card, Apple Pay, Google Pay and Alipay) |
|
|
|
|
|--------------------------------------------------|--------------------------------------------------|--------------------------------------------------|
|
|
|
|
| [USD](https://buy.stripe.com/cN203sdZB98RevC3cd) | [SEK](https://buy.stripe.com/bIYbMa9JletbevCaEE) | [CNY](https://buy.stripe.com/dR67vU4p13Ox73a6oq) |
|
|
|
|
|  |  |  |
|
2022-01-02 21:49:03 +08:00
|
|
|
|
2021-05-04 12:01:53 +08:00
|
|
|
# License
|
2021-08-29 10:19:49 +08:00
|
|
|
|
2022-12-06 09:53:03 +08:00
|
|
|
Apache License 2.0
|