mirror of
https://github.com/tgbot-collection/ytdlbot.git
synced 2025-02-22 14:23:20 +08:00
add comments
This commit is contained in:
parent
b97955153c
commit
0ac49e12b4
4 changed files with 26 additions and 21 deletions
14
.env.example
14
.env.example
|
@ -12,22 +12,22 @@ APP_HASH=
|
|||
# Telegram bot token
|
||||
BOT_TOKEN=
|
||||
|
||||
# Owner ID, separate by ,
|
||||
# Owner ID, comma-separated
|
||||
OWNER=
|
||||
|
||||
# List of authorized users (comma-separated)
|
||||
# List of authorized users, comma-separated
|
||||
AUTHORIZED_USER=
|
||||
|
||||
# database Data Source Name
|
||||
# database Data Source Name, i.e. mysql+pymysql://user:pass@mysql/dbname SQLite sqlite:///db.sqlite
|
||||
DB_DSN=
|
||||
|
||||
# Redis host
|
||||
REDIS_HOST=
|
||||
# Redis host, leave it empty to use fakeredis
|
||||
REDIS_HOST=redis
|
||||
|
||||
# Enable FFMPEG for video processing (True/False)
|
||||
ENABLE_FFMPEG=False
|
||||
|
||||
# Desired audio format (e.g., mp3, wav)
|
||||
# Desired audio format (e.g., mp3, wav), leave it empty to use m4a
|
||||
AUDIO_FORMAT=
|
||||
|
||||
# Enable Aria2 for downloads (True/False)
|
||||
|
@ -39,7 +39,7 @@ RCLONE_PATH=
|
|||
# Enable VIP features (True/False)
|
||||
ENABLE_VIP=False
|
||||
|
||||
# Payment provider token
|
||||
# Payment provider token from Bot Father
|
||||
PROVIDER_TOKEN=
|
||||
|
||||
# Free downloads allowed per user
|
||||
|
|
17
README.md
17
README.md
|
@ -3,7 +3,6 @@
|
|||
[](https://github.com/tgbot-collection/ytdlbot/actions/workflows/builder.yaml)
|
||||
|
||||
**YouTube Download Bot🚀🎬⬇️**
|
||||
🧰Refactor ongoing🧰
|
||||
|
||||
This Telegram bot allows you to download videos from YouTube and [other supported websites](#supported-websites).
|
||||
|
||||
|
@ -38,7 +37,7 @@ Just send a link directly to the bot.
|
|||
|
||||
> ## Limitations
|
||||
> Due to limitations on servers and bandwidth, there are some restrictions on this free service.
|
||||
> * Each user is limited to 3 free downloads every day.
|
||||
> * Each user is limited to 1 free downloads every day.
|
||||
|
||||
# Screenshots
|
||||
|
||||
|
@ -66,7 +65,7 @@ This bot can be deployed on any platform that supports Python.
|
|||
or for more ways: [Official Docs](https://pdm-project.org/en/latest/#installation)
|
||||
</details>
|
||||
|
||||
2. Install modules using PDM: `pdm install`, or the old way use `requirements.txt`
|
||||
2. Install modules using PDM: `pdm install`, or the old way use `pip install -r requirements.txt`
|
||||
|
||||
3. <details>
|
||||
<summary>Setting up config file</summary>
|
||||
|
@ -75,7 +74,7 @@ This bot can be deployed on any platform that supports Python.
|
|||
cp .env.example .env
|
||||
```
|
||||
|
||||
Fill the fields in `.env`.
|
||||
Fill the fields in `.env`. For more information, see the comments in the `.env.example` file.
|
||||
|
||||
**- Required Fields**
|
||||
- `WORKERS`: Number of workers (default is 100)
|
||||
|
@ -83,8 +82,8 @@ This bot can be deployed on any platform that supports Python.
|
|||
- `APP_HASH`: Telegram app hash
|
||||
- `BOT_TOKEN`: Your telegram bot token
|
||||
- `OWNER`: Owner ID (separate by `,`)
|
||||
- `AUTHORIZED_USER`: List of authorized users (separate by `,`)
|
||||
- `DB_DSN`: Your database URL (mysql+pymysql://user:pass@some_mariadb/dbname)
|
||||
- `AUTHORIZED_USER`: List of authorized users ids, (separate by `,`)
|
||||
- `DB_DSN`: Your database URL (mysql+pymysql://user:pass@mysql/dbname) or SQLite (sqlite:///db.sqlite)
|
||||
- `REDIS_HOST`: Redis host
|
||||
|
||||
**- Optional Fields**
|
||||
|
@ -93,14 +92,14 @@ This bot can be deployed on any platform that supports Python.
|
|||
- `ENABLE_ARIA2`: Enable Aria2 for downloads (True/False)
|
||||
- `RCLONE_PATH`: Path to Rclone executable
|
||||
- `ENABLE_VIP`: Enable VIP features (True/False)
|
||||
- `PROVIDER_TOKEN`: Payment provider token
|
||||
- `PROVIDER_TOKEN`: Payment provider token from Stripe
|
||||
- `FREE_DOWNLOAD`: Free downloads allowed per user
|
||||
- `RATE_LIMIT`: Rate limit for requests
|
||||
- `TMPFILE_PATH`: Path for temporary/download files (ensure the directory exists and is writable)
|
||||
- `TG_NORMAL_MAX_SIZE`: Maximum size for Telegram uploads in MB
|
||||
- `CAPTION_URL_LENGTH_LIMIT`: Maximum URL length in captions
|
||||
- `POTOKEN`: Your PO Token. [PO-Token-Guide](https://github.com/yt-dlp/yt-dlp/wiki/PO-Token-Guide)
|
||||
- `BROWSERS`: Browser to handle 'cookies from browser'
|
||||
- `BROWSERS`: Browser to handle 'cookies from browser', i.e. firefox
|
||||
</details>
|
||||
|
||||
4. Activate virtual environment that created by PDM: `source .venv/bin/activate`
|
||||
|
@ -112,7 +111,7 @@ This bot can be deployed on any platform that supports Python.
|
|||
One line command to run the bot
|
||||
|
||||
```shell
|
||||
docker run -e APP_ID=111 -e APP_HASH=111 -e TOKEN=370FXI bennythink/ytdlbot
|
||||
docker run --env-file .env bennythink/ytdlbot
|
||||
```
|
||||
|
||||
# Command
|
||||
|
|
|
@ -18,5 +18,5 @@ with open("requirements.txt", "w") as file:
|
|||
file.write(f"{item}\n")
|
||||
|
||||
# commit with amend
|
||||
subprocess.run(["git", "add", "requirements.txt"])
|
||||
subprocess.run(["git", "commit", "-m", "pre-push"])
|
||||
# subprocess.run(["git", "add", "requirements.txt"])
|
||||
# subprocess.run(["git", "commit", "-m", "pre-push"])
|
||||
|
|
|
@ -11,6 +11,7 @@ import yt_dlp
|
|||
|
||||
from database.model import get_format_settings, get_quality_settings
|
||||
from engine.base import BaseDownloader
|
||||
from config import AUDIO_FORMAT
|
||||
|
||||
|
||||
def match_filter(info_dict):
|
||||
|
@ -38,14 +39,15 @@ class YoutubeDownload(BaseDownloader):
|
|||
"bestvideo[vcodec^=avc]+bestaudio[acodec^=mp4a]/best[vcodec^=avc]/best",
|
||||
None,
|
||||
]
|
||||
audio = AUDIO_FORMAT or "m4a"
|
||||
maps = {
|
||||
"high-audio": ["bestaudio[ext=m4a]"],
|
||||
"high-audio": [f"bestaudio[ext=={audio}]"],
|
||||
"high-video": defaults,
|
||||
"high-document": defaults,
|
||||
"medium-audio": ["bestaudio[ext=m4a]"], # no mediumaudio :-(
|
||||
"medium-audio": [f"bestaudio[ext={audio}]"], # no mediumaudio :-(
|
||||
"medium-video": self.get_format(720),
|
||||
"medium-document": self.get_format(720),
|
||||
"low-audio": ["bestaudio[ext=m4a]"],
|
||||
"low-audio": [f"bestaudio[ext={audio}]"],
|
||||
"low-video": self.get_format(480),
|
||||
"low-document": self.get_format(480),
|
||||
"custom-audio": "",
|
||||
|
@ -100,6 +102,10 @@ class YoutubeDownload(BaseDownloader):
|
|||
# try add extract_args if present
|
||||
if potoken := os.getenv("POTOKEN"):
|
||||
ydl_opts["extractor_args"] = {"youtube": ["player-client=web,default", f"po_token=web+{potoken}"]}
|
||||
# for new version? https://github.com/yt-dlp/yt-dlp/wiki/PO-Token-Guide
|
||||
# ydl_opts["extractor_args"] = {
|
||||
# "youtube": [f"po_token=web.player+{potoken}", f"po_token=web.gvs+{potoken}"]
|
||||
# }
|
||||
|
||||
if self._url.startswith("https://drive.google.com"):
|
||||
# Always use the `source` format for Google Drive URLs.
|
||||
|
|
Loading…
Reference in a new issue