Merge pull request #1584 from Xpl0itU/develop
Use yt-dlp for downloading the background videos
This commit is contained in:
2 files changed
+11
-7
No files matched your search
+2
-2
@@ -5,7 +5,6 @@ moviepy==1.0.3
|
||||
playwright==1.23.0
|
||||
praw==7.6.1
|
||||
prawcore~=2.3.0
|
||||
pytube==12.1.0
|
||||
requests==2.28.1
|
||||
rich==13.3.1
|
||||
toml==0.10.2
|
||||
@@ -19,4 +18,5 @@ unidecode==1.3.2
|
||||
spacy==3.4.1
|
||||
torch==1.12.1
|
||||
transformers==4.25.1
|
||||
ffmpeg-python==0.2.0
|
||||
ffmpeg-python==0.2.0
|
||||
yt-dlp==2023.3.4
|
||||
@@ -7,10 +7,9 @@ from typing import Any, Tuple
|
||||
|
||||
from moviepy.editor import VideoFileClip
|
||||
from moviepy.video.io.ffmpeg_tools import ffmpeg_extract_subclip
|
||||
from pytube import YouTube
|
||||
from pytube.cli import on_progress
|
||||
from utils import settings
|
||||
from utils.console import print_step, print_substep
|
||||
import yt_dlp
|
||||
|
||||
# Load background videos
|
||||
with open("./utils/backgrounds.json") as json_file:
|
||||
@@ -72,9 +71,14 @@ def download_background(background_config: Tuple[str, str, str, Any]):
|
||||
)
|
||||
print_substep("Downloading the backgrounds videos... please be patient 🙏 ")
|
||||
print_substep(f"Downloading {filename} from {uri}")
|
||||
YouTube(uri, on_progress_callback=on_progress).streams.filter(
|
||||
res="1080p"
|
||||
).first().download("assets/backgrounds", filename=f"{credit}-{filename}")
|
||||
ydl_opts = {
|
||||
'format': "bestvideo[height<=1080][ext=mp4]",
|
||||
"outtmpl": f"assets/backgrounds/{credit}-{filename}",
|
||||
"retries": 10,
|
||||
}
|
||||
|
||||
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
|
||||
ydl.download(uri)
|
||||
print_substep("Background video downloaded successfully! 🎉", style="bold green")
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user