Fix small bugs and path issues
This commit is contained in:
1 parent
c58fa10f53
commit
7765c9b018
4 files changed
+24
-9
No files matched your search
@@ -28,7 +28,7 @@ class TTSEngine:
|
||||
self,
|
||||
tts_module,
|
||||
reddit_object: dict,
|
||||
path: str = "assets/mp3",
|
||||
path: str = "assets/temp/mp3",
|
||||
max_length: int = 50,
|
||||
):
|
||||
self.tts_module = tts_module()
|
||||
@@ -54,7 +54,6 @@ class TTSEngine:
|
||||
self.reddit_object["thread_post"] != ""
|
||||
and getenv("STORYMODE", "").casefold() == "true"
|
||||
):
|
||||
|
||||
self.call_tts("posttext", sanitize_text(self.reddit_object["thread_post"]))
|
||||
|
||||
idx = None
|
||||
|
||||
+13
-5
@@ -31,7 +31,9 @@ def get_subreddit_threads():
|
||||
|
||||
content = {}
|
||||
if str(getenv("REDDIT_2FA")).casefold() == "yes":
|
||||
print("\nEnter your two-factor authentication code from your authenticator app.\n")
|
||||
print(
|
||||
"\nEnter your two-factor authentication code from your authenticator app.\n"
|
||||
)
|
||||
code = input("> ")
|
||||
print()
|
||||
pw = getenv("REDDIT_PASSWORD")
|
||||
@@ -55,14 +57,18 @@ def get_subreddit_threads():
|
||||
): # 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? "))
|
||||
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")
|
||||
print_substep(
|
||||
f"Using subreddit: r/{getenv('SUBREDDIT')} from environment variable config"
|
||||
)
|
||||
subreddit = reddit.subreddit(
|
||||
getenv("SUBREDDIT")
|
||||
) # Allows you to specify in .env. Done for automation purposes.
|
||||
@@ -83,12 +89,14 @@ def get_subreddit_threads():
|
||||
print_substep(f"Thread has {upvotes} upvotes", style="bold blue")
|
||||
print_substep(f"Thread has a upvote ratio of {ratio}%", style="bold blue")
|
||||
print_substep(f"Thread has {num_comments} comments", style="bold blue")
|
||||
environ["VIDEO_TITLE"] = str(textify(submission.title)) # todo use global instend of env vars
|
||||
environ["VIDEO_TITLE"] = str(
|
||||
textify(submission.title)
|
||||
) # todo use global instend of env vars
|
||||
environ["VIDEO_ID"] = str(textify(submission.id))
|
||||
|
||||
content["thread_url"] = f"https://reddit.com{submission.permalink}"
|
||||
content["thread_title"] = submission.title
|
||||
# content["thread_content"] = submission.content
|
||||
content["thread_post"] = submission.selftext
|
||||
content["comments"] = []
|
||||
for top_level_comment in submission.comments:
|
||||
if isinstance(top_level_comment, MoreComments):
|
||||
|
||||
+1
-1
@@ -17,6 +17,6 @@ def sanitize_text(text):
|
||||
# note: not removing apostrophes
|
||||
regex_expr = r"\s['|’]|['|’]\s|[\^_~@!&;#:\-%“”‘\"%\*/{}\[\]\(\)\\|<>=+]"
|
||||
result = re.sub(regex_expr, " ", result)
|
||||
result = result.replace("+", "plus").replace(" ", "+").replace("&", "and")
|
||||
result = result.replace("+", "plus").replace("&", "and")
|
||||
# remove extra whitespace
|
||||
return " ".join(result.split())
|
||||
@@ -1 +1,9 @@
|
||||
[]
|
||||
[
|
||||
{
|
||||
"id": "vfxpph",
|
||||
"time": "1655671664",
|
||||
"background_credit": "bbswitzer",
|
||||
"reddit_title": "What unimpressive things are people idiotically proud of",
|
||||
"filename": "What unimpressive things are p....mp4"
|
||||
}
|
||||
]
|
||||
Reference in new issue
Block a user