From 055b18514e04b9f7f51714934e0fb783fef15f4e Mon Sep 17 00:00:00 2001 From: BennyThink Date: Tue, 19 Oct 2021 18:58:48 +0800 Subject: [PATCH] yt-dlp #18 #15 --- downloader.py | 11 ++++++++--- requirements.txt | 3 ++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/downloader.py b/downloader.py index 5440b77..397f7ab 100644 --- a/downloader.py +++ b/downloader.py @@ -15,8 +15,13 @@ import time import fakeredis import filetype -import yt_dlp -from yt_dlp import DownloadError + +if os.getenv("downloader") == "youtube-dl": + import youtube_dl as ytdl + from youtube_dl import DownloadError +else: + import yt_dlp as ytdl + from yt_dlp import DownloadError from config import ENABLE_VIP from limit import VIP, Redis @@ -123,7 +128,7 @@ def ytdl_download(url, tempdir, bm) -> dict: ydl_opts["format"] = f try: logging.info("Downloading for %s with format %s", url, f) - with yt_dlp.YoutubeDL(ydl_opts) as ydl: + with ytdl.YoutubeDL(ydl_opts) as ydl: ydl.download([url]) response["status"] = True response["error"] = "" diff --git a/requirements.txt b/requirements.txt index 4d50b49..2cfcfa0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,7 @@ pyrogram==1.2.9 tgcrypto==1.2.2 -yt-dlp +yt-dlp==2021.10.10 +youtube-dl==2021.6.6 APScheduler==3.7.0 beautifultable==1.0.1 ffmpeg-python==0.2.0