take file as custom background input

pull/280/head
iaacornus 3 years ago
parent a824182be8
commit f589ca7b6f
No known key found for this signature in database
GPG Key ID: 281739AE7252598C

@ -26,8 +26,6 @@ def program_options():
help="Use another sub-reddit.", help="Use another sub-reddit.",
action="store" action="store"
) )
# this one accepts link as input, defaults to the minecraft video
# does not accept file or already downloaded background yet.
parser.add_argument( parser.add_argument(
"-b", "-b",
"--background", "--background",

@ -2,6 +2,7 @@ import re
import os import os
from random import randrange from random import randrange
from pathlib import Path from pathlib import Path
from turtle import back
from yt_dlp import YoutubeDL from yt_dlp import YoutubeDL
from moviepy.video.io.ffmpeg_tools import ffmpeg_extract_subclip from moviepy.video.io.ffmpeg_tools import ffmpeg_extract_subclip
@ -42,12 +43,15 @@ def download_background(background):
if background is None: if background is None:
ydl.download("https://www.youtube.com/watch?v=n_Dv4JMiwK8") ydl.download("https://www.youtube.com/watch?v=n_Dv4JMiwK8")
elif background is not None: elif background is not None:
if ( check_link = re.match(
re.match("https://www.youtube.com/watch?v*", background.strip()) "https://www.youtube.com/watch?v*", background.strip()
and background is not None )
): if check_link and background is not None:
print_substep(f"Downloading video from: {background}", style="bold") print_substep(f"Downloading video from: {background}", style="bold")
ydl.download(background) ydl.download(background)
elif background is not None and not check_link:
print_substep(f"Using the given video file: {background}", style="bold")
os.replace(background.strip(), "assets/mp4/background.mp4")
else: # if the link is not youtube link else: # if the link is not youtube link
raise ValueError raise ValueError
except ( except (

Loading…
Cancel
Save