|
|
@ -31,7 +31,9 @@ def get_subreddit_threads():
|
|
|
|
|
|
|
|
|
|
|
|
content = {}
|
|
|
|
content = {}
|
|
|
|
if str(getenv("REDDIT_2FA")).casefold() == "yes":
|
|
|
|
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("> ")
|
|
|
|
code = input("> ")
|
|
|
|
print()
|
|
|
|
print()
|
|
|
|
pw = getenv("REDDIT_PASSWORD")
|
|
|
|
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")
|
|
|
|
): # note to user. you can have multiple subreddits via reddit.subreddit("redditdev+learnpython")
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
subreddit = reddit.subreddit(
|
|
|
|
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
|
|
|
|
# removes the r/ from the input
|
|
|
|
)
|
|
|
|
)
|
|
|
|
except ValueError:
|
|
|
|
except ValueError:
|
|
|
|
subreddit = reddit.subreddit("askreddit")
|
|
|
|
subreddit = reddit.subreddit("askreddit")
|
|
|
|
print_substep("Subreddit not defined. Using AskReddit.")
|
|
|
|
print_substep("Subreddit not defined. Using AskReddit.")
|
|
|
|
else:
|
|
|
|
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(
|
|
|
|
subreddit = reddit.subreddit(
|
|
|
|
getenv("SUBREDDIT")
|
|
|
|
getenv("SUBREDDIT")
|
|
|
|
) # Allows you to specify in .env. Done for automation purposes.
|
|
|
|
) # 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 {upvotes} upvotes", style="bold blue")
|
|
|
|
print_substep(f"Thread has a upvote ratio of {ratio}%", 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")
|
|
|
|
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))
|
|
|
|
environ["VIDEO_ID"] = str(textify(submission.id))
|
|
|
|
|
|
|
|
|
|
|
|
content["thread_url"] = f"https://reddit.com{submission.permalink}"
|
|
|
|
content["thread_url"] = f"https://reddit.com{submission.permalink}"
|
|
|
|
content["thread_title"] = submission.title
|
|
|
|
content["thread_title"] = submission.title
|
|
|
|
# content["thread_content"] = submission.content
|
|
|
|
content["thread_post"] = submission.selftext
|
|
|
|
content["comments"] = []
|
|
|
|
content["comments"] = []
|
|
|
|
for top_level_comment in submission.comments:
|
|
|
|
for top_level_comment in submission.comments:
|
|
|
|
if isinstance(top_level_comment, MoreComments):
|
|
|
|
if isinstance(top_level_comment, MoreComments):
|
|
|
|