added the changes of #549
This commit is contained in:
1 parent
99978b1cf1
commit
56ad559339
4 files changed
+23
-10
No files matched your search
+2
-2
@@ -239,5 +239,5 @@ results/*
|
||||
reddit-bot-351418-5560ebc49cac.json
|
||||
/.idea
|
||||
*.pyc
|
||||
/video_creation/data/videos.json
|
||||
/video_creation/data/envvars.txt
|
||||
video_creation/data/videos.json
|
||||
video_creation/data/envvars.txt
|
||||
+6
-1
@@ -5,6 +5,7 @@ from dotenv import load_dotenv
|
||||
from TTS.GTTS import GTTS
|
||||
from TTS.POLLY import POLLY
|
||||
from TTS.TikTok import TikTok
|
||||
from utils.console import print_substep
|
||||
|
||||
CHOICE_DIR = {"tiktok": TikTok, "gtts": GTTS, "polly": POLLY}
|
||||
|
||||
@@ -12,7 +13,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(f"{CHOICE} is not valid. Please use one of these {valid_keys} options")
|
||||
|
||||
+9
-4
@@ -1,3 +1,4 @@
|
||||
import re
|
||||
from os import getenv, environ
|
||||
|
||||
import praw
|
||||
@@ -44,10 +45,14 @@ def get_subreddit_threads():
|
||||
print_step("Getting subreddit threads...")
|
||||
if not getenv(
|
||||
"SUBREDDIT"
|
||||
): # note to self. you can have multiple subreddits via reddit.subreddit("redditdev+learnpython")
|
||||
subreddit = reddit.subreddit(
|
||||
input("What subreddit would you like to pull from? ")
|
||||
) # if the env isnt set, ask user
|
||||
): # note to user. you can have multiple subreddits via reddit.subreddit("redditdev+learnpython")
|
||||
try:
|
||||
subreddit = reddit.subreddit(
|
||||
re.sub(r"r\/", "", input("What subreddit would you like to pull from? ")) # removes the r/ from the input
|
||||
)
|
||||
except ValueError:
|
||||
subreddit = reddit.subreddit("askreddit")
|
||||
print_substep("Subreddit not defined. Using AskReddit.")
|
||||
else:
|
||||
print_substep(f"Using subreddit: r/{getenv('SUBREDDIT')} from environment variable config")
|
||||
subreddit = reddit.subreddit(
|
||||
|
||||
+6
-3
@@ -14,9 +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...")
|
||||
continue
|
||||
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...")
|
||||
return submission
|
||||
print("all submissions have been done going by top submission order")
|
||||
return get_subreddit_undone(
|
||||
|
||||
Reference in new issue
Block a user