Allow user to choose thread

Added option for user to chose the thread they want from r/askreddit
pull/84/head
TornadoMC 3 years ago committed by GitHub
parent 5b3989611f
commit b62e788ce2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -22,8 +22,15 @@ def get_askreddit_threads():
password=os.getenv("REDDIT_PASSWORD"), password=os.getenv("REDDIT_PASSWORD"),
) )
askreddit = reddit.subreddit("askreddit") askreddit = reddit.subreddit("askreddit")
threads = askreddit.hot(limit=25) # change to update number of choices that show up in console
submission = list(threads)[random.randrange(0, 25)] number_choices = 25
choices_string = ""
number = 1
for thread in askreddit.hot(limit=number_choices):
choices_string += f"{number}) {thread.title}\n"
number += 1
submissionChoice = input(f"{choices_string}\nWhich thread would you like to use? ")
submission = list(askreddit.hot(limit=number_choices))[int(submissionChoice) - 1]
print_substep(f"Video will be: {submission.title} :thumbsup:") print_substep(f"Video will be: {submission.title} :thumbsup:")
try: try:

Loading…
Cancel
Save