From 74a602b42cce64d6c4c237791f83ed44d05cb6ca Mon Sep 17 00:00:00 2001 From: final Date: Sat, 16 Jul 2022 21:05:22 -0500 Subject: [PATCH] Adjusted code as per Drugsosos suggested --- main.py | 2 -- utils/settings.py | 4 ++-- video_creation/final_video.py | 12 +++++------- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/main.py b/main.py index 81f94fd..10ab3c1 100755 --- a/main.py +++ b/main.py @@ -13,7 +13,6 @@ from video_creation.background import ( get_background_config, ) from video_creation.final_video import make_final_video -from video_creation.final_video import change_background_resolution from video_creation.screenshot_downloader import download_screenshots_of_reddit_posts from video_creation.voices import save_text_to_mp3 @@ -39,7 +38,6 @@ print_step(f"You are using v{__VERSION__} of the bot") def main(POST_ID=None): cleanup() - change_background_resolution() reddit_object = get_subreddit_threads(POST_ID) length, number_of_comments = save_text_to_mp3(reddit_object) length = math.ceil(length) diff --git a/utils/settings.py b/utils/settings.py index 5b1a8fb..90321a8 100755 --- a/utils/settings.py +++ b/utils/settings.py @@ -3,13 +3,13 @@ import toml from rich.console import Console import re -from typing import Tuple, Dict +from typing import Tuple, Dict, Union from utils.console import handle_input console = Console() -config: dict | None = None # autocomplete +config: Union[dict, None] = None # autocomplete def crawl(obj: dict, func=lambda x, y: print(x, y, end="\n"), path=None): diff --git a/video_creation/final_video.py b/video_creation/final_video.py index 579737d..086856f 100755 --- a/video_creation/final_video.py +++ b/video_creation/final_video.py @@ -19,13 +19,6 @@ from utils.videos import save_data from utils import settings console = Console() -W, H = 1080, 1920 - - -def change_background_resolution(): - global W - global H - W, H = settings.config["settings"]["background"]["width"], settings.config["settings"]["background"]["height"] def name_normalize(name: str) -> str: @@ -66,6 +59,11 @@ def make_final_video( # except (TypeError, KeyError): # print('No background audio volume found in config.toml. Using default value of 1.') # VOLUME_MULTIPLIER = 1 + W: int = settings.config["settings"]["background"]["width"] + H: int = settings.config["settings"]["background"]["height"] + + if not W or not H: + W, H = 1080, 1920 print_step("Creating the final video 🎥") VideoFileClip.reW = lambda clip: clip.resize(width=W) VideoFileClip.reH = lambda clip: clip.resize(width=H)