diff --git a/.gitignore b/.gitignore index 67554cf..f120e44 100644 --- a/.gitignore +++ b/.gitignore @@ -140,3 +140,4 @@ dmypy.json /*.sqlite /.idea/dataSources.xml /.idea/sqldialects.xml +/.idea/.gitignore diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 73f69e0..0000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml -# Datasource local storage ignored files -/dataSources/ -/dataSources.local.xml -# Editor-based HTTP Client requests -/httpRequests/ diff --git a/README.md b/README.md index 50940eb..d0e6e0d 100644 --- a/README.md +++ b/README.md @@ -1,39 +1,97 @@ -# ytdl-bot +# ytdlbot + +YouTube Download🚀 + Download videos from YouTube and other platforms through a Telegram Bot [![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy) -# Usage: +# Usage [https://t.me/benny_ytdlbot](https://t.me/benny_ytdlbot) -Send link from YouTube directly to the bot. -Any platform [supported by youtube-dl](https://ytdl-org.github.io/youtube-dl/supportedsites.html) will also work. +Send link directly to the bot. Any +platform [supported by youtube-dl](https://ytdl-org.github.io/youtube-dl/supportedsites.html) will also work. + +## Limitation of my bot + +Because I have limited resources, hundreds of Gigabytes doesn't sound like a sustainable solution. + +**In that case, I added one limitation: 5GiB per 24 hours for each user. Might change in future** + +You can choose to become 'VIP' if you really need large traffic. And also, you could always deploy your own bot. + +# Features -# Feature ![](assets/1.jpeg) -1. fast download and upload. Many thanks to [FastTelethon](https://gist.github.com/painor/7e74de80ae0c819d3e9abcf9989a8dd6) and -[JasonKhew96](https://github.com/JasonKhew96)'s contribution on this! -2. ads free - I'll never send ads to you, also I don't even print logs that will identify you. - So feel free to download any type of video from any website. - -3. support progress bar +1. fast download and upload. +2. ads free +3. support progress bar +4. audio conversion +5. playlist support +6. VIP support # How to deploy? + ## Normal -1. clone code and update submodule `git submodule update --init --recursive` -2. install ffmpeg + +1. clone code +2. install ffmpeg 3. install Python 3.6+ 4. pip3 install -r requirements.txt -5. set environment variables `TOKEN`, `APP_ID` and `APP_HASH` -6. `python3 bot.py` -7. supervisor on your own preference. +5. set environment variables `TOKEN`, `APP_ID` and `APP_HASH`, and more if you like. +6. `python3 ytdl.py` ## docker -see [here](https://github.com/tgbot-collection/BotsRunner) + +Compatible with amd64, arm64 and armv7l + +### 1. get docker-compose.yml + +Download this file to a directory, for example `~/ytdl/docker-compose.yml` + +### 2. create VIP database + +```shell +mkdir ~/ytdl/data/ +touch ~/ytdl/data/vip.sqlite +``` + +### 3. create env file + +```shell +mkdir ~/ytdl/env/ +vim ~/ytdl/env/ytdl.env +``` + +you can configure all the following environment variables: + +* APP_ID: **REQUIRED** +* APP_HASH: **REQUIRED** +* TOKEN: **REQUIRED** +* REDIS: **REQUIRED** +* OWNER: owner username +* QUOTA: quota in bytes +* EX: quota expire time +* MULTIPLY: vip quota comparing to normal quota +* USD2CNY: exchange rate +* VIP: enable VIP or not, default: disable +* AFD_LINK +* COFFEE_LINK +* COFFEE_TOKEN +* AFD_TOKEN +* AFD_USER_ID +* WORKERS: default 100 + +### 4. run + +``` +docker-compose up -d +``` # Command + ``` start - Let's start about - Want to contribute? @@ -45,10 +103,13 @@ terms - View Terms of Service ``` # Test video + https://www.youtube.com/watch?v=BaW_jenozKc # Test Playlist + https://www.youtube.com/playlist?list=PL1Hdq7xjQCJxQnGc05gS4wzHWccvEJy0w # License + Apache License 2.0 diff --git a/config.py b/config.py index 8d9b06b..2239f02 100644 --- a/config.py +++ b/config.py @@ -9,15 +9,15 @@ __author__ = "Benny " import os -QUOTA = 5 * 1024 * 1024 * 1024 # 5G +QUOTA = os.getenv("QUOTA", 5 * 1024 * 1024 * 1024) # 5G if os.uname().sysname == "Darwin": QUOTA = 10 * 1024 * 1024 # 10M -EX = 24 * 3600 -MULTIPLY = 5 # VIP1 is 5*5-25G, VIP2 is 50G -USD2CNY = 6 # $5 --> ¥30 +EX = os.getenv("EX", 24 * 3600) +MULTIPLY = os.getenv("MULTIPLY", 5) # VIP1 is 5*5-25G, VIP2 is 50G +USD2CNY = os.getenv("USD2CNY", 6) # $5 --> ¥30 -ENABLE_VIP = False +ENABLE_VIP = os.getenv("VIP", False) AFD_LINK = os.getenv("AFD_LINK", "https://afdian.net/@BennyThink") COFFEE_LINK = os.getenv("COFFEE_LINK", "https://www.buymeacoffee.com/bennythink") COFFEE_TOKEN = os.getenv("COFFEE_TOKEN") diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..66e1aed --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,26 @@ +version: '3.1' + +services: + socat: + image: jmb12686/socat + restart: always + volumes: + - /var/run/docker.sock:/var/run/docker.sock + entrypoint: [ "socat", "tcp-listen:2375,fork,reuseaddr","unix-connect:/var/run/docker.sock" ] + + redis: + image: redis:alpine + restart: always + logging: + driver: none + + ytdl: + image: bennythink/ytdlbot + env_file: + - env/ytdl.env + volumes: + - ./data/vip.sqlite:/ytdlbot/vip.sqlite + restart: always + depends_on: + - socat + - redis \ No newline at end of file