From ed86199141cdd2ceaf196c1c66c70b5f703a1e5b Mon Sep 17 00:00:00 2001 From: Owen Gaspard Date: Sat, 18 Jun 2022 11:41:11 -0500 Subject: [PATCH] Allow TTsChoice and ALLOW_NSFW to be blank All these changes to the .env file make it annoying to keep updating. This allows the TTsChoice and ALLOW_NSFW variables to be left blank in the event that someone doesn't update the .env file. Also, videos.json in the .gitignore was not seen by GH Desktop, and it kept wanting to push that too. I made a change in the .gitignore. --- .gitignore | 2 +- TTS/swapper.py | 6 +++++- utils/subreddit.py | 8 ++++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 2701ca5..e77539e 100644 --- a/.gitignore +++ b/.gitignore @@ -169,4 +169,4 @@ results/* reddit-bot-351418-5560ebc49cac.json /.idea *.pyc -/video_creation/data/videos.json \ No newline at end of file +video_creation/data/videos.json diff --git a/TTS/swapper.py b/TTS/swapper.py index f4717b1..a6c089f 100644 --- a/TTS/swapper.py +++ b/TTS/swapper.py @@ -12,7 +12,11 @@ CHOICE_DIR = {"tiktok": TikTok, "gtts": GTTS, 'polly': POLLY} class TTS: def __new__(cls): load_dotenv() - CHOICE = getenv("TTsChoice").casefold() + try: + CHOICE = getenv("TTsChoice").casefold() + except AttributeError: + print_substep("None defined. Defaulting to 'polly.'") + CHOICE = "polly" valid_keys = [key.lower() for key in CHOICE_DIR.keys()] if CHOICE not in valid_keys: raise ValueError( diff --git a/utils/subreddit.py b/utils/subreddit.py index 2a1114a..7d578c4 100644 --- a/utils/subreddit.py +++ b/utils/subreddit.py @@ -14,8 +14,12 @@ def get_subreddit_undone(submissions: List, subreddit): if already_done(done_videos, submission): continue if submission.over_18: - if getenv("ALLOW_NSFW").casefold() == "false": - print_substep("NSFW Post Detected. Skipping...") + try: + if getenv("ALLOW_NSFW").casefold() == "false": + print_substep("NSFW Post Detected. Skipping...") + continue + except AttributeError: + print_substep("NSFW settings not defined. Skipping NSFW post...") continue return submission print('all submissions have been done going by top submission order')