From 828fb37336a7cb0c26ed1a901e130fb01d6ad4cd Mon Sep 17 00:00:00 2001 From: kennydd0 <76538784+kennydd0@users.noreply.github.com> Date: Tue, 1 Jul 2025 12:20:24 +0200 Subject: [PATCH] Fix storymode boolean checks and add TTS listing --- main.py | 17 ++++++++++++++++- reddit/subreddit.py | 2 +- video_creation/final_video.py | 2 +- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index 849663d..f18656b 100755 --- a/main.py +++ b/main.py @@ -6,6 +6,7 @@ from pathlib import Path from subprocess import Popen from typing import NoReturn +import argparse from prawcore import ResponseException from reddit.subreddit import get_subreddit_threads @@ -23,7 +24,7 @@ from video_creation.background import ( ) from video_creation.final_video import make_final_video from video_creation.screenshot_downloader import get_screenshots_of_reddit_posts -from video_creation.voices import save_text_to_mp3 +from video_creation.voices import save_text_to_mp3, TTSProviders __VERSION__ = "3.3.0" @@ -79,6 +80,20 @@ def shutdown() -> NoReturn: if __name__ == "__main__": + parser = argparse.ArgumentParser(description="Reddit Video Maker Bot") + parser.add_argument( + "--list-tts", + action="store_true", + help="List available TTS providers and exit", + ) + args = parser.parse_args() + + if args.list_tts: + print_step("Available TTS Providers:") + for provider in TTSProviders: + print_substep(f"- {provider}") + sys.exit() + if sys.version_info.major != 3 or sys.version_info.minor not in [10, 11]: print( "Hey! Congratulations, you've made it so far (which is pretty rare with no Python 3.10). Unfortunately, this program only works on Python 3.10. Please install Python 3.10 and try again." diff --git a/reddit/subreddit.py b/reddit/subreddit.py index 5f2ac5f..f9e6179 100644 --- a/reddit/subreddit.py +++ b/reddit/subreddit.py @@ -95,7 +95,7 @@ def get_subreddit_threads(POST_ID: str): if submission is None: return get_subreddit_threads(POST_ID) # submission already done. rerun - elif not submission.num_comments and settings.config["settings"]["storymode"] == "false": + elif not submission.num_comments and not settings.config["settings"]["storymode"]: print_substep("No comments found. Skipping.") exit() diff --git a/video_creation/final_video.py b/video_creation/final_video.py index 101d0f7..6a616a1 100644 --- a/video_creation/final_video.py +++ b/video_creation/final_video.py @@ -217,7 +217,7 @@ def make_final_video( # Gather all audio clips audio_clips = list() - if number_of_clips == 0 and settings.config["settings"]["storymode"] == "false": + if number_of_clips == 0 and not settings.config["settings"]["storymode"]: print( "No audio clips to gather. Please use a different TTS or post." ) # This is to fix the TypeError: unsupported operand type(s) for +: 'int' and 'NoneType'