fixed merge conflicts and cleared up some old existing .env referances
chore: updated version num style: improved IDE autocorrection support chore: simplified the regex in func name_normalize
This commit is contained in:
1 parent
73d15fe3ad
commit
9ae01b7c19
6 files changed
+10
-31
No files matched your search
@@ -1,11 +1,8 @@
|
||||
import random
|
||||
from os import listdir
|
||||
from pathlib import Path
|
||||
import random
|
||||
from random import randrange
|
||||
from typing import Any, Tuple
|
||||
|
||||
from dotenv import load_dotenv
|
||||
|
||||
from moviepy.editor import VideoFileClip
|
||||
from moviepy.video.io.ffmpeg_tools import ffmpeg_extract_subclip
|
||||
@@ -48,21 +45,7 @@ background_options = {
|
||||
lambda t: ('center', 480 + t)
|
||||
)
|
||||
}
|
||||
def get_background_config():
|
||||
"""Fetch the background/s configuration"""
|
||||
try:
|
||||
choice = str(settings.config['settings']['background_choice']).casefold()
|
||||
except AttributeError:
|
||||
print_substep("No background selected. Picking random background'")
|
||||
choice = None
|
||||
|
||||
# Handle default / not supported background using default option.
|
||||
# Default : pick random from supported background.
|
||||
if not choice or choice not in background_options:
|
||||
choice = random.choice(list(background_options.keys()))
|
||||
|
||||
return background_options[choice]
|
||||
|
||||
def get_start_and_end_times(video_length: int, length_of_clip: int) -> Tuple[int, int]:
|
||||
"""Generates a random interval of time to be used as the background of the video.
|
||||
|
||||
@@ -76,12 +59,10 @@ def get_start_and_end_times(video_length: int, length_of_clip: int) -> Tuple[int
|
||||
random_time = randrange(180, int(length_of_clip) - int(video_length))
|
||||
return random_time, random_time + video_length
|
||||
|
||||
|
||||
def get_background_config():
|
||||
"""Fetch the background/s configuration"""
|
||||
load_dotenv()
|
||||
try:
|
||||
choice = getenv("BackgroundChoice").casefold()
|
||||
choice = str(settings.config['settings']['background_choice']).casefold()
|
||||
except AttributeError:
|
||||
print_substep("No background selected. Picking random background'")
|
||||
choice = None
|
||||
@@ -123,8 +104,6 @@ def chop_background_video(background_config: Tuple[str, str, str, Any], video_le
|
||||
|
||||
print_step("Finding a spot in the backgrounds video to chop...✂️")
|
||||
choice = f"{background_config[2]}-{background_config[1]}"
|
||||
environ["background_credit"] = choice.split("-")[0]
|
||||
|
||||
|
||||
background = VideoFileClip(f"assets/backgrounds/{choice}")
|
||||
|
||||
@@ -143,4 +122,4 @@ def chop_background_video(background_config: Tuple[str, str, str, Any], video_le
|
||||
new = video.subclip(start_time, end_time)
|
||||
new.write_videofile("assets/temp/background.mp4")
|
||||
print_substep("Background video chopped successfully!", style="bold green")
|
||||
return credit
|
||||
return background_config[2]
|
||||
@@ -49,10 +49,10 @@ def name_normalize(name: str) -> str:
|
||||
def make_final_video(number_of_clips: int, length: int, reddit_obj: dict, background_config: Tuple[str, str, str, Any]):
|
||||
"""Gathers audio clips, gathers all screenshots, stitches them together and saves the final video to assets/temp
|
||||
Args:
|
||||
number_of_clips (int): Index to end at when going through the screenshots
|
||||
number_of_clips (int): Index to end at when going through the screenshots'
|
||||
length (int): Length of the video
|
||||
reddit_obj (dict): The reddit object that contains the posts to read.
|
||||
background_config Tuple[str, str, str, Any]: The background config to use.
|
||||
background_config (Tuple[str, str, str, Any]): The background config to use.
|
||||
"""
|
||||
print_step("Creating the final video 🎥")
|
||||
VideoFileClip.reW = lambda clip: clip.resize(width=W)
|
||||
@@ -103,7 +103,7 @@ def make_final_video(number_of_clips: int, length: int, reddit_obj: dict, backgr
|
||||
# .resize(width=W - 100)
|
||||
# .set_opacity(float(opacity)),
|
||||
# )
|
||||
# else:
|
||||
# else: story mode stuff
|
||||
img_clip_pos = background_config[3]
|
||||
image_concat = concatenate_videoclips(
|
||||
image_clips).set_position(img_clip_pos)
|
||||
|
||||
Reference in new issue
Block a user