make aria2 optional

This commit is contained in:
Benny 2023-03-04 19:11:09 +01:00
parent 0f3dd86cd4
commit 9a9de982a7
No known key found for this signature in database
GPG key ID: 6CD0DBDA5235D481
3 changed files with 14 additions and 8 deletions

View file

@ -1,7 +1,7 @@
pyrogram==1.4.16
tgcrypto==1.2.5
git+https://github.com/yt-dlp/yt-dlp
APScheduler==3.9.1.post1
yt-dlp==2023.3.3
APScheduler==3.10.0
beautifultable==1.1.0
ffmpeg-python==0.2.0
PyMySQL==1.0.2
@ -10,10 +10,10 @@ filetype==1.2.0
flower==1.2.0
psutil==5.9.4
influxdb==5.3.1
beautifulsoup4==4.11.1
fakeredis==2.6.0
beautifulsoup4==4.11.2
fakeredis==2.9.2
supervisor==4.2.5
tgbot-ping==1.0.6
tgbot-ping==1.0.7
redis==4.3.3
requests==2.28.2
tqdm==4.64.1

View file

@ -63,3 +63,4 @@ RATE = float(os.getenv("RATE", 0.01))
BURST = int(os.getenv("BURST", 3))
PROVIDER_TOKEN = os.getenv("PROVIDER_TOKEN") or "1234"
PLAYLIST_SUPPORT = os.getenv("PLAYLIST_SUPPORT", False)
ENABLE_ARIA2 = os.getenv("ENABLE_ARIA2", False)

View file

@ -24,7 +24,7 @@ import filetype
import yt_dlp as ytdl
from tqdm import tqdm
from config import (AUDIO_FORMAT, ENABLE_FFMPEG, ENABLE_VIP, MAX_DURATION,
from config import (AUDIO_FORMAT, ENABLE_FFMPEG, ENABLE_VIP, MAX_DURATION, ENABLE_ARIA2,
TG_MAX_SIZE, IPv6)
from db import Redis
from limit import VIP
@ -190,14 +190,19 @@ def ytdl_download(url, tempdir, bm, **kwargs) -> dict:
response = {"status": True, "error": "", "filepath": []}
output = pathlib.Path(tempdir, "%(title).70s.%(ext)s").as_posix()
ydl_opts = {
'external_downloader': 'aria2c',
'external_downloader_args': ['--min-split-size=1M', '--max-connection-per-server=16', '--max-concurrent-downloads=16', '--split=16'],
'progress_hooks': [lambda d: download_hook(d, bm)],
'outtmpl': output,
'restrictfilenames': False,
'quiet': True,
"proxy": os.getenv("YTDL_PROXY")
}
if ENABLE_ARIA2:
ydl_opts["external_downloader"] = "aria2c"
ydl_opts["external_downloader_args"] = ['--min-split-size=1M',
'--max-connection-per-server=16',
'--max-concurrent-downloads=16',
'--split=16'
]
formats = [
"bestvideo[ext=mp4]+bestaudio[ext=m4a]/bestvideo+bestaudio",
"bestvideo[vcodec^=avc]+bestaudio[acodec^=mp4a]/best[vcodec^=avc]/best",