2021-08-29 02:19:49 +00:00
|
|
|
# ytdlbot
|
|
|
|
|
2022-01-02 13:49:03 +00:00
|
|
|
[![docker image](https://github.com/tgbot-collection/ytdlbot/actions/workflows/builder.yaml/badge.svg)](https://github.com/tgbot-collection/ytdlbot/actions/workflows/builder.yaml)
|
|
|
|
|
2021-08-30 14:06:32 +00:00
|
|
|
YouTube Download Bot🚀
|
2021-08-29 02:19:49 +00:00
|
|
|
|
2021-05-04 04:01:53 +00:00
|
|
|
Download videos from YouTube and other platforms through a Telegram Bot
|
|
|
|
|
2022-01-02 13:49:03 +00:00
|
|
|
-----
|
|
|
|
|
2021-05-23 14:25:15 +00:00
|
|
|
[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy)
|
2021-05-04 04:01:53 +00:00
|
|
|
|
2022-01-02 13:49:03 +00:00
|
|
|
Can't deploy? Fork to your personal account and deploy it there!
|
|
|
|
|
2021-08-29 02:19:49 +00:00
|
|
|
# Usage
|
2021-05-04 04:01:53 +00:00
|
|
|
|
|
|
|
[https://t.me/benny_ytdlbot](https://t.me/benny_ytdlbot)
|
|
|
|
|
2021-08-29 02:19:49 +00:00
|
|
|
Send link directly to the bot. Any
|
2022-01-02 13:49:03 +00:00
|
|
|
Websites [supported by youtube-dl](https://ytdl-org.github.io/youtube-dl/supportedsites.html) will also work.
|
2021-05-04 04:01:53 +00:00
|
|
|
|
2022-01-02 13:49:03 +00:00
|
|
|
# Limitations of my bot
|
2021-08-29 02:19:49 +00:00
|
|
|
|
2022-01-02 13:49:03 +00:00
|
|
|
I don't have unlimited servers and bandwidth, so I have to make some restrictions.
|
2021-05-05 04:07:03 +00:00
|
|
|
|
2022-01-20 01:58:42 +00:00
|
|
|
**In that case, I added one limitation: 10 GiB per 24 hours for each user. Might change in future**
|
2021-08-29 02:19:49 +00:00
|
|
|
|
|
|
|
You can choose to become 'VIP' if you really need large traffic. And also, you could always deploy your own bot.
|
|
|
|
|
|
|
|
# Features
|
|
|
|
|
|
|
|
![](assets/1.jpeg)
|
2021-05-05 04:07:03 +00:00
|
|
|
|
2021-08-29 02:19:49 +00:00
|
|
|
1. fast download and upload.
|
|
|
|
2. ads free
|
|
|
|
3. support progress bar
|
|
|
|
4. audio conversion
|
|
|
|
5. playlist support
|
|
|
|
6. VIP support
|
2021-12-07 13:32:06 +00:00
|
|
|
7. support different video resolutions
|
|
|
|
8. support sending as file or streaming as video
|
2022-01-02 13:49:03 +00:00
|
|
|
9. supports celery worker distribution - faster than before.
|
2021-12-07 13:32:06 +00:00
|
|
|
|
2022-01-02 13:49:03 +00:00
|
|
|
![](assets/2.jpeg)
|
2021-05-05 04:07:03 +00:00
|
|
|
|
2021-05-04 05:36:28 +00:00
|
|
|
# How to deploy?
|
2021-08-29 02:19:49 +00:00
|
|
|
|
2021-12-07 13:32:06 +00:00
|
|
|
You can deploy this bot on any platform that supports Python.
|
2021-08-30 14:42:54 +00:00
|
|
|
|
|
|
|
## Heroku
|
|
|
|
|
2022-01-02 13:49:03 +00:00
|
|
|
Use the button above! It should work like a magic but with limited functionalities.
|
2021-08-30 14:42:54 +00:00
|
|
|
|
2022-01-02 13:49:03 +00:00
|
|
|
## Run natively on your machine
|
2021-08-29 02:19:49 +00:00
|
|
|
|
|
|
|
1. clone code
|
|
|
|
2. install ffmpeg
|
2021-05-05 06:10:08 +00:00
|
|
|
3. install Python 3.6+
|
|
|
|
4. pip3 install -r requirements.txt
|
2021-08-29 02:19:49 +00:00
|
|
|
5. set environment variables `TOKEN`, `APP_ID` and `APP_HASH`, and more if you like.
|
2022-01-02 13:49:03 +00:00
|
|
|
6. `python3 ytdl_bot.py`
|
2021-05-05 04:07:03 +00:00
|
|
|
|
2022-01-02 13:49:03 +00:00
|
|
|
## Docker
|
2021-08-30 14:42:54 +00:00
|
|
|
|
|
|
|
Some functions, such as VIP, ping will be disabled.
|
|
|
|
|
|
|
|
```shell
|
|
|
|
docker run -e APP_ID=111 -e APP_HASH=111 -e TOKEN=370FXI bennythink/ytdlbot
|
|
|
|
```
|
|
|
|
|
2022-01-02 13:49:03 +00:00
|
|
|
# Complete deployment guide for docker-compose
|
2021-08-29 02:19:49 +00:00
|
|
|
|
2022-01-02 13:49:03 +00:00
|
|
|
* contains every functionality
|
|
|
|
* compatible with amd64, arm64 and armv7l
|
2021-08-29 02:19:49 +00:00
|
|
|
|
2022-01-02 13:49:03 +00:00
|
|
|
## 1. get docker-compose.yml
|
2021-08-29 02:19:49 +00:00
|
|
|
|
2022-01-02 13:49:03 +00:00
|
|
|
Download `docker-compose.yml` file to a directory
|
2021-08-29 02:19:49 +00:00
|
|
|
|
2022-01-02 13:49:03 +00:00
|
|
|
## 2. create data directory
|
2021-08-29 02:19:49 +00:00
|
|
|
|
|
|
|
```shell
|
2022-01-02 13:49:03 +00:00
|
|
|
mkdir data
|
|
|
|
mkdir env
|
2021-08-29 02:19:49 +00:00
|
|
|
```
|
|
|
|
|
2022-01-02 13:49:03 +00:00
|
|
|
## 3. configuration
|
|
|
|
|
|
|
|
### 3.1. set environment variables
|
2021-08-29 02:19:49 +00:00
|
|
|
|
|
|
|
```shell
|
2022-01-02 13:49:03 +00:00
|
|
|
vim env/ytdl.env
|
2021-08-29 02:19:49 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
you can configure all the following environment variables:
|
2021-12-07 13:32:06 +00:00
|
|
|
|
2022-01-02 13:49:03 +00:00
|
|
|
* WORKERS: default 200
|
2021-08-29 02:19:49 +00:00
|
|
|
* APP_ID: **REQUIRED**
|
|
|
|
* APP_HASH: **REQUIRED**
|
|
|
|
* TOKEN: **REQUIRED**
|
2022-01-02 13:49:03 +00:00
|
|
|
* REDIS: **REQUIRED** ⚠️ Don't publish your redis server on the internet. ⚠️
|
2021-10-30 06:27:43 +00:00
|
|
|
|
2021-08-29 02:19:49 +00:00
|
|
|
* OWNER: owner username
|
|
|
|
* QUOTA: quota in bytes
|
|
|
|
* EX: quota expire time
|
|
|
|
* MULTIPLY: vip quota comparing to normal quota
|
|
|
|
* USD2CNY: exchange rate
|
2022-01-02 13:49:03 +00:00
|
|
|
* VIP: VIP mode, default: disable
|
2021-08-29 02:19:49 +00:00
|
|
|
* AFD_LINK
|
|
|
|
* COFFEE_LINK
|
|
|
|
* COFFEE_TOKEN
|
|
|
|
* AFD_TOKEN
|
|
|
|
* AFD_USER_ID
|
2021-10-30 06:27:43 +00:00
|
|
|
|
|
|
|
* AUTHORIZED_USER: users that could use this bot, user_id, separated with `,`
|
2021-12-07 13:32:06 +00:00
|
|
|
* REQUIRED_MEMBERSHIP: group or channel username, user must join this group to use the bot. Could be use with
|
|
|
|
above `AUTHORIZED_USER`
|
2021-08-29 02:19:49 +00:00
|
|
|
|
2022-01-02 13:49:03 +00:00
|
|
|
* ENABLE_CELERY: Distribution mode, default: disable. You'll can setup workers in different locations.
|
|
|
|
* MYSQL_HOST: you'll have to setup MySQL if you enable VIP mode
|
|
|
|
* MYSQL_USER
|
|
|
|
* MYSQL_PASS
|
|
|
|
|
|
|
|
## 3.2 Set up init data
|
|
|
|
|
|
|
|
### 3.2.1 Create MySQL db
|
|
|
|
|
|
|
|
```shell
|
|
|
|
docker-compose up -d
|
|
|
|
docker-compose exec mysql bash
|
|
|
|
|
|
|
|
mysql -u root -p
|
|
|
|
|
|
|
|
> create database vip;
|
|
|
|
```
|
|
|
|
|
|
|
|
### 3.2.2 Setup flower db in `ytdlbot/ytdlbot/data`
|
2021-08-29 02:19:49 +00:00
|
|
|
|
2022-01-02 13:49:03 +00: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 02:19:49 +00:00
|
|
|
```
|
2022-01-02 13:49:03 +00:00
|
|
|
|
|
|
|
### 3.2.3 Setup instagram cookies
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
2022-01-03 02:26:03 +00:00
|
|
|
You can also limit CPU and RAM usage by adding an `deploy' key:
|
|
|
|
|
|
|
|
```docker
|
|
|
|
deploy:
|
|
|
|
resources:
|
|
|
|
limits:
|
|
|
|
cpus: '0.5'
|
|
|
|
memory: 1500M
|
|
|
|
```
|
|
|
|
|
|
|
|
Be sure to use `--compatibility` when deploying.
|
|
|
|
|
2022-01-02 13:49:03 +00: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
|
|
|
|
|
|
|
|
You'll have to start MySQL and redis to support VIP mode.
|
|
|
|
|
|
|
|
```
|
|
|
|
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 02:19:49 +00:00
|
|
|
docker-compose up -d
|
|
|
|
```
|
2021-05-04 04:01:53 +00:00
|
|
|
|
2022-01-02 13:49:03 +00:00
|
|
|
On the other machine:
|
|
|
|
|
|
|
|
```shell
|
|
|
|
docker-compose -f worker up -d
|
|
|
|
```
|
|
|
|
|
|
|
|
**⚠️ Bear in mind don't publish redis directly on the internet! You can use WireGuard to wrap it up.**
|
|
|
|
|
2021-05-05 06:10:08 +00:00
|
|
|
# Command
|
2021-08-29 02:19:49 +00:00
|
|
|
|
2021-05-05 04:07:03 +00:00
|
|
|
```
|
2021-08-16 11:45:36 +00:00
|
|
|
start - Let's start
|
|
|
|
about - Want to contribute?
|
|
|
|
ping - Bot running status
|
2021-08-25 14:13:25 +00:00
|
|
|
help - Anything troubles you?
|
2021-08-16 11:45:36 +00:00
|
|
|
ytdl - Download video in group
|
|
|
|
vip - Join VIP
|
|
|
|
terms - View Terms of Service
|
2021-12-07 13:32:06 +00:00
|
|
|
settings - Set your preference
|
2022-01-20 13:01:58 +00:00
|
|
|
direct - Download file directly
|
2021-05-05 04:07:03 +00:00
|
|
|
```
|
2021-05-05 06:10:08 +00:00
|
|
|
|
2022-01-04 13:33:03 +00:00
|
|
|
# Test data
|
|
|
|
|
|
|
|
## Test video
|
2021-08-29 02:19:49 +00:00
|
|
|
|
2021-05-05 06:10:08 +00:00
|
|
|
https://www.youtube.com/watch?v=BaW_jenozKc
|
|
|
|
|
2022-01-04 13:33:03 +00:00
|
|
|
## Test Playlist
|
2021-08-29 02:19:49 +00:00
|
|
|
|
2021-08-24 11:56:13 +00:00
|
|
|
https://www.youtube.com/playlist?list=PL1Hdq7xjQCJxQnGc05gS4wzHWccvEJy0w
|
|
|
|
|
2022-01-04 13:33:03 +00:00
|
|
|
## Test m3u8
|
|
|
|
|
|
|
|
https://dmesg.app/m3u8/prog_index.m3u8
|
|
|
|
|
2022-01-02 13:49:03 +00:00
|
|
|
# Donation
|
|
|
|
|
|
|
|
* [Buy me a coffee](https://www.buymeacoffee.com/bennythink)
|
|
|
|
* [Afdian](https://afdian.net/@BennyThink)
|
|
|
|
|
2021-05-04 04:01:53 +00:00
|
|
|
# License
|
2021-08-29 02:19:49 +00:00
|
|
|
|
2021-05-04 04:01:53 +00:00
|
|
|
Apache License 2.0
|