Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tron #318

Merged
merged 4 commits into from
Dec 8, 2023
Merged

Tron #318

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 0 additions & 25 deletions FAQ.md

This file was deleted.

81 changes: 42 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,10 @@

[![docker image](https://github.com/tgbot-collection/ytdlbot/actions/workflows/builder.yaml/badge.svg)](https://github.com/tgbot-collection/ytdlbot/actions/workflows/builder.yaml)

YouTube Download Bot🚀
YouTube Download Bot🚀🎬⬇️

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

-----
**READ [FAQ](FAQ.md) FIRST IF YOU ENCOUNTER ANY ISSUES.**

-----
<details> <summary>Deploy to heroku</summary>

<a href="https://heroku.com/deploy"><img src="https://www.herokucdn.com/deploy/button.svg" alt="Deploy to Heroku"></a>
Expand All @@ -26,14 +22,14 @@ longer be available.**
[https://t.me/benny_ytdlbot](https://t.me/benny_ytdlbot)

Send link directly to the bot. Any
Websites [supported by youtube-dl](https://ytdl-org.github.io/youtube-dl/supportedsites.html) will work to.
Websites [supported by yt-dlp](https://github.com/yt-dlp/yt-dlp/blob/master/supportedsites.md) will work t0o.

# 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.
* 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.
Expand All @@ -44,14 +40,14 @@ own bot. See below instructions.
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.
5. playlist download
6. payment support: afdian, buy me a coffee, Telegram Payment and Tron(TRX)
7. different video resolutions
8. sending as file or streaming as video
9. celery worker distribution - faster than before.
10. subscriptions to YouTube Channels
11. cache mechanism - download once for the same video.
12. support instagram posts
12. instagram posts

# Screenshots

Expand All @@ -71,19 +67,17 @@ own bot. See below instructions.

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.
* (optional)Aria2 and add it to the PATH.

2. Clone the code from the repository and cd into it.
* ```Bash
git clone "https://github.com/tgbot-collection/ytdlbot.git
git clone https://github.com/tgbot-collection/ytdlbot
```
* ```Bash
cd ytdlbot/
Expand All @@ -93,9 +87,9 @@ To deploy this bot, follow these steps:
python -m venv venv
```
* ```Bash
source venv/bin/activate #Linux
source venv/bin/activate # Linux
#or
.\venv\Scripts\activate #Windows
.\venv\Scripts\activate # Windows
```
* ```Python
pip install --upgrade pip
Expand All @@ -105,14 +99,15 @@ To deploy this bot, follow these steps:
```
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
* Use export APP_ID=111 APP_HASH=111 TOKEN=123
5. Finally, run the bot with
* ```Python
python ytdl_bot.py
```

## Docker

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

```shell
docker run -e APP_ID=111 -e APP_HASH=111 -e TOKEN=370FXI bennythink/ytdlbot
Expand All @@ -121,7 +116,7 @@ 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
* compatible with amd64 and arm64

## 1. get docker-compose.yml

Expand Down Expand Up @@ -174,14 +169,16 @@ You can configure all the following environment variables:
* 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)
* TRONGRID_KEY: TronGrid key, better use your own key to avoid rate limit
* TRON_MNEMONIC: Tron mnemonic, the default one is on nile testnet.

## 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.
Required for VIP(Download token), settings, YouTube subscription.

```shell
docker-compose up -d
Expand All @@ -204,15 +201,11 @@ 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:
You can also limit CPU and RAM usage by adding a `deploy` key, use `--compatibility` when deploying.

```docker
deploy:
Expand All @@ -222,8 +215,6 @@ You can also limit CPU and RAM usage by adding a `deploy' key:
memory: 1500M
```

Be sure to use `--compatibility` when deploying.

## 4. run

### 4.1. standalone mode
Expand Down Expand Up @@ -256,7 +247,7 @@ 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.
**⚠️ You should not publish Redis directly on the internet.
Instead, you can use WireGuard to wrap it up for added security.**

## kubernetes
Expand Down Expand Up @@ -306,20 +297,32 @@ https://www.instagram.com/p/CZtUDyyv1u1/

# Donation

Found this bot useful? You can donate to support the development of this bot.

## Donation Platforms

* [Buy me a coffee](https://www.buymeacoffee.com/bennythink)
* [Afdian](https://afdian.net/@BennyThink)
* [GitHub Sponsor](https://github.com/sponsors/BennyThink)

## Stripe

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

| USD(Card, Apple Pay and Google Pay) | CNY(Card, Apple Pay, Google Pay and Alipay) |
|--------------------------------------------------|--------------------------------------------------|
| [USD](https://buy.stripe.com/cN203sdZB98RevC3cd) | [CNY](https://buy.stripe.com/dR67vU4p13Ox73a6oq) |
| ![](assets/USD.png) | ![](assets/CNY.png) |

## Cryptocurrency

Select the currency and payment method that suits you.
TRX or USDT(TRC20)

| 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) |
| ![](assets/USD.png) | ![](assets/SEK.png) | ![](assets/CNY.png) |
![](assets/tron.png)

```
TF9peZjC2FYjU4xNMPg3uP4caYLJxtXeJS
```

# License

Expand Down
Binary file removed assets/SEK.png
Binary file not shown.
Binary file added assets/tron.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 5 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ APScheduler==3.10.4
beautifultable==1.1.0
ffmpeg-python==0.2.0
PyMySQL==1.1.0
celery==5.3.5
celery==5.3.6
filetype==1.2.0
flower==2.0.1
psutil==5.9.6
Expand All @@ -22,3 +22,7 @@ ffpb==0.4.1
youtube-search-python==1.6.6
token-bucket==0.3.0
coloredlogs==15.0.1
tronpy==0.4.0
mnemonic==0.20
qrcode==7.4.2
blinker==1.7.0
28 changes: 28 additions & 0 deletions scripts/transfer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env python3
# coding: utf-8

# ytdlbot - transfer.py
# 2023-12-07 18:21
from tronpy import Tron
from tronpy.hdwallet import seed_from_mnemonic, key_from_seed
from tronpy.keys import PrivateKey

mnemonic = "web horse smile ramp olive slush blue property world physical donkey pumpkin"

client = Tron(network="nile")

from_ = client.generate_address_from_mnemonic(mnemonic, account_path="m/44'/195'/0'/0/0")["base58check_address"]
print("my addr: ", from_)
to = input("to: ")
amount = int(input("amount: 1_000_000\n"))


def mnemonic_to_private_key():
seed = seed_from_mnemonic(mnemonic, passphrase="")
private_key = key_from_seed(seed, account_path="m/44'/195'/0'/0/0")
return PrivateKey(private_key)


t = client.trx.transfer(from_, to, amount).build().inspect().sign(mnemonic_to_private_key()).broadcast()

print(t.wait())
26 changes: 16 additions & 10 deletions ytdlbot/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

import os

from blinker import signal

# general settings
WORKERS: int = int(os.getenv("WORKERS", 100))
PYRO_WORKERS: int = int(os.getenv("PYRO_WORKERS", min(64, (os.cpu_count() + 4) * 10)))
Expand All @@ -24,11 +26,6 @@
EXPIRE = 24 * 3600

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")
AFD_TOKEN = os.getenv("AFD_TOKEN")
AFD_USER_ID = os.getenv("AFD_USER_ID")
OWNER = os.getenv("OWNER", "BennyThink")

# limitation settings
Expand All @@ -52,16 +49,11 @@
IPv6 = os.getenv("IPv6", False)
ENABLE_FFMPEG = os.getenv("ENABLE_FFMPEG", False)

# Stripe setting
PROVIDER_TOKEN = os.getenv("PROVIDER_TOKEN") or "1234"

PLAYLIST_SUPPORT = os.getenv("PLAYLIST_SUPPORT", False)
M3U8_SUPPORT = os.getenv("M3U8_SUPPORT", False)
ENABLE_ARIA2 = os.getenv("ENABLE_ARIA2", False)

FREE_DOWNLOAD = os.getenv("FREE_DOWNLOAD", 20)
TOKEN_PRICE = os.getenv("BUY_UNIT", 20) # one USD=20 credits

RATE_LIMIT = os.getenv("RATE_LIMIT", 120)

SS_YOUTUBE = os.getenv("SS_YOUTUBE", "https://ytdlbot.dmesg.app?token=123456")
Expand All @@ -72,3 +64,17 @@
# Please ensure that the directory exists and you have necessary permissions to write to it.
# If you don't know what this is just leave it as it is.
TMPFILE_PATH = os.getenv("TMPFILE")

# payment settings
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")
AFD_TOKEN = os.getenv("AFD_TOKEN")
AFD_USER_ID = os.getenv("AFD_USER_ID")
PROVIDER_TOKEN = os.getenv("PROVIDER_TOKEN") or "1234"
FREE_DOWNLOAD = os.getenv("FREE_DOWNLOAD", 20)
TOKEN_PRICE = os.getenv("BUY_UNIT", 20) # one USD=20 credits
TRONGRID_KEY = os.getenv("TRONGRID_KEY", "").split(",")
# the default mnemonic is for nile testnet
TRON_MNEMONIC = os.getenv("TRON_MNEMONIC", "cram floor today legend service drill pitch leaf car govern harvest soda")
TRX_SIGNAL = signal("trx_received")
Loading
Loading