diff --git a/main.py b/main.py index ded1f2c..fb987c1 100755 --- a/main.py +++ b/main.py @@ -41,7 +41,7 @@ async def main(POST_ID=None): cleanup() reddit_object = get_subreddit_threads(POST_ID) comments_created = save_text_to_mp3(reddit_object) - webdriver = screenshot_factory(config["settings"]["times_to_run"]) # TODO add in config + webdriver = screenshot_factory(config["settings"]["webdriver"]) await webdriver(reddit_object, comments_created).download() bg_config = get_background_config() FinalVideo().make(comments_created, reddit_object, bg_config) @@ -83,7 +83,7 @@ if __name__ == "__main__": Popen("cls" if name == "nt" else "clear", shell=True).wait() else: main() - except KeyboardInterrupt: # TODO wont work with async code + except KeyboardInterrupt: # TODO won't work with async code shutdown() except ResponseException: # error for invalid credentials diff --git a/utils/.config.template.toml b/utils/.config.template.toml index d703fb3..503e4d0 100644 --- a/utils/.config.template.toml +++ b/utils/.config.template.toml @@ -16,7 +16,8 @@ subreddit = { optional = false, regex = "[_0-9a-zA-Z]+$", nmin = 3, explanation post_id = { optional = true, default = "", regex = "^((?!://|://)[+a-zA-Z])*$", explanation = "Used if you want to use a specific post.", example = "urdtfx" } max_comment_length = { default = 500, optional = false, nmin = 10, nmax = 10000, type = "int", explanation = "max number of characters a comment can have. default is 500", example = 500, oob_error = "the max comment length should be between 10 and 10000" } post_lang = { default = "", optional = true, explanation = "The language you would like to translate to.", example = "es-cr" } -min_comments = { default = 20, optional = false, nmin = 15, type = "int", explanation = "The minimum number of comments a post should have to be included. default is 20", example = 29, oob_error = "the minimum number of comments should be between 15 and 999999" } +min_comments = { default = 20, optional = false, nmin = 15, type = "int", explanation = "The minimum number of comments a post should have to be included. default is 20", example = 29, oob_error = "the minimum number of comments must be at least 15" } + [settings] allow_nsfw = { optional = false, type = "bool", default = false, example = false, options = [true, false, @@ -35,7 +36,8 @@ time_before_tts = { optional = false, default = 0.5, example = 1.0, explanation time_between_pictures = { optional = false, default = 0.5, example = 1.0, explanation = "Time between every screenshot", type = "float", nmin = 0, oob_error = "Choose at least 0 second" } delay_before_end = { optional = false, default = 0.5, example = 1.0, explanation = "Deley before video ends", type = "float", nmin = 0, oob_error = "Choose at least 0 second" } video_width = { optional = true, default = 1080, example = 1080, explanation = "Final video width", type = "int", nmin = 600, oob_error = "Choose at least 600 pixels wide" } -video_height = { optional = true, default = 1920, example = 1920, explanation = "Final video height", type = "int", nmin = 800, oob_error = "Choose at least 800 pixels long" } +video_height = { optional = true, default = 1920, example = 1920, explanation = "Final video height", type = "int", nmin = 600, oob_error = "Choose at least 600 pixels long" } +webdriver = { optional = true, default = "pyppeteer", example = "pyppeteer", options = ["pyppeteer", "playwright"], explanation = "Driver used to take screenshots (use pyppeteer if you have some problems with playwright)"} [settings.background] background_choice = { optional = true, default = "minecraft", example = "minecraft", options = ["minecraft", "gta", "rocket-league", "motor-gta", "csgo-surf", "cluster-truck", ""], explanation = "Sets the background for the video" } diff --git a/utils/settings.py b/utils/settings.py index 43796bd..5f764e2 100755 --- a/utils/settings.py +++ b/utils/settings.py @@ -3,7 +3,7 @@ import toml from rich.console import Console import re -from typing import Tuple, Dict, Optional +from typing import Dict, Optional, Union from utils.console import handle_input @@ -108,7 +108,7 @@ def check_vars(path, checks): crawl_and_check(config, path, checks) -def check_toml(template_file, config_file) -> Tuple[bool, Dict]: +def check_toml(template_file, config_file) -> Union[bool, Dict]: global config config = None try: diff --git a/webdriver/web_engine.py b/webdriver/web_engine.py index 2ca28ab..42d5853 100644 --- a/webdriver/web_engine.py +++ b/webdriver/web_engine.py @@ -1,11 +1,12 @@ from typing import Union from webdriver.pyppeteer import RedditScreenshot as Pyppeteer +from webdriver.playwright import RedditScreenshot as Playwright def screenshot_factory( driver: str, -) -> Union[Pyppeteer]: +) -> Union[type(Pyppeteer), type(Playwright)]: """ Factory for webdriver Args: @@ -16,7 +17,7 @@ def screenshot_factory( """ web_drivers = { "pyppeteer": Pyppeteer, - "playwright": None, + "playwright": Playwright, } return web_drivers[driver]