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
pull/879/head
Jason 3 years ago
parent 73d15fe3ad
commit 9ae01b7c19

@ -37,7 +37,7 @@ class AWSPolly:
else:
if not settings.config["settings"]["tts"]["aws_polly_voice"]:
return ValueError(
f"Please set the environment variable AWS_VOICE to a valid voice. options are: {voices}"
f"Please set the TOML variable AWS_VOICE to a valid voice. options are: {voices}"
)
voice = str(
settings.config["settings"]["tts"]["aws_polly_voice"]

@ -37,7 +37,7 @@ class StreamlabsPolly:
else:
if not settings.config["settings"]["tts"]["streamlabs_polly_voice"]:
return ValueError(
f"Please set the environment variable STREAMLABS_VOICE to a valid voice. options are: {voices}"
f"Please set the config variable STREAMLABS_VOICE to a valid voice. options are: {voices}"
)
voice = str(
settings.config["settings"]["tts"]["streamlabs_polly_voice"]

@ -13,7 +13,7 @@ from video_creation.final_video import make_final_video
from video_creation.screenshot_downloader import download_screenshots_of_reddit_posts
from video_creation.voices import save_text_to_mp3
VERSION = "2.2.8"
VERSION = "2.2.9"
print(
"""

@ -28,7 +28,7 @@ def check_done(
if video["id"] == str(redditobj):
if settings.config["reddit"]["thread"]["post_id"]:
print_step(
"You already have done this video but since it was declared specifically in the .env file the program will continue"
"You already have done this video but since it was declared specifically in the config file the program will continue"
)
return redditobj
print_step("Getting new post as the current one has already been done")
@ -48,7 +48,7 @@ def save_data(filename: str, reddit_title: str, reddit_id: str, credit: str):
with open("./video_creation/data/videos.json", "r+", encoding="utf-8") as raw_vids:
done_vids = json.load(raw_vids)
if reddit_id in [video["id"] for video in done_vids]:
return # video already done but was specified to continue anyway in the .env file
return # video already done but was specified to continue anyway in the config file
payload = {
"id": reddit_id,
"time": str(int(time.time())),

@ -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)

Loading…
Cancel
Save