Improved download and annoying user fixes/redundancies

pull/518/head
Jason 2 years ago
parent 809bae88c9
commit 6937f10e1b

@ -7,9 +7,6 @@ from moviepy.video.io.ffmpeg_tools import ffmpeg_extract_subclip
from moviepy.editor import VideoFileClip from moviepy.editor import VideoFileClip
from utils.console import print_step, print_substep from utils.console import print_step, print_substep
import datetime
def get_start_and_end_times(video_length, length_of_clip): def get_start_and_end_times(video_length, length_of_clip):
random_time = randrange(180, int(length_of_clip) - int(video_length)) random_time = randrange(180, int(length_of_clip) - int(video_length))
return random_time, random_time + video_length return random_time, random_time + video_length
@ -20,14 +17,14 @@ def download_background():
Path("./assets/backgrounds/").mkdir(parents=True, exist_ok=True) Path("./assets/backgrounds/").mkdir(parents=True, exist_ok=True)
background_options = [ # uri , filename , credit background_options = [ # uri , filename , credit
("https://www.youtube.com/watch?v=n_Dv4JMiwK8", "parkour.mp4", "bbswitzer"), ("https://www.youtube.com/watch?v=n_Dv4JMiwK8", "parkour.mp4", "bbswitzer"),
( #(
"https://www.youtube.com/watch?v=2X9QGY__0II", # "https://www.youtube.com/watch?v=2X9QGY__0II",
"rocket_league.mp4", # "rocket_league.mp4",
"Orbital Gameplay", # "Orbital Gameplay",
), #),
] ]
# note: make sure the file name doesn't include a - in it # note: make sure the file name doesn't include an - in it
if len(listdir("./assets/backgrounds")) != len( if not len(listdir("./assets/backgrounds")) <= len(
background_options background_options
): # if there are any background videos not installed ): # if there are any background videos not installed
print_step( print_step(
@ -35,6 +32,8 @@ def download_background():
) )
print_substep("Downloading the backgrounds videos... please be patient 🙏 ") print_substep("Downloading the backgrounds videos... please be patient 🙏 ")
for uri, filename, credit in background_options: for uri, filename, credit in background_options:
if Path(f'assets/backgrounds/{credit}-{filename}').is_file():
continue # adds check to see if file exists before downloading
print_substep(f"Downloading {filename} from {uri}") print_substep(f"Downloading {filename} from {uri}")
YouTube(uri).streams.filter(res="1080p").first().download( YouTube(uri).streams.filter(res="1080p").first().download(
"assets/backgrounds", filename=f"{credit}-{filename}" "assets/backgrounds", filename=f"{credit}-{filename}"
@ -60,5 +59,4 @@ def chop_background_video(video_length):
targetname="assets/temp/background.mp4", targetname="assets/temp/background.mp4",
) )
print_substep("Background video chopped successfully!", style="bold green") print_substep("Background video chopped successfully!", style="bold green")
noerror = True return True
return noerror

Loading…
Cancel
Save