From b62e788ce23a0a78bf2fce8074635455c55e38b7 Mon Sep 17 00:00:00 2001 From: TornadoMC <42751295+TornadoMC2@users.noreply.github.com> Date: Wed, 1 Jun 2022 10:56:03 -0500 Subject: [PATCH] Allow user to choose thread Added option for user to chose the thread they want from r/askreddit --- reddit/askreddit.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/reddit/askreddit.py b/reddit/askreddit.py index 7c7110a..66dc0ca 100644 --- a/reddit/askreddit.py +++ b/reddit/askreddit.py @@ -22,8 +22,15 @@ def get_askreddit_threads(): password=os.getenv("REDDIT_PASSWORD"), ) askreddit = reddit.subreddit("askreddit") - threads = askreddit.hot(limit=25) - submission = list(threads)[random.randrange(0, 25)] + # change to update number of choices that show up in console + 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:") try: