The script asks the user for the thread link in the console

pull/238/head
Domiziano Scarcelli 3 years ago
parent 3284a1cb4d
commit f51cbbce4d

@ -12,6 +12,5 @@ SUBREDDIT="askReddit"
THEME="" THEME=""
# Link of the thread #If no, it will ask you a thread link to extract the thread, if yes it will randomize it.
# (e.g. https://www.reddit.com/r/memes/comments/sbr31o/discordggrmemes_the_official_rmemes_discord_server/) RANDOM_THREAD="no"
THREAD_LINK=""

@ -1,3 +1,6 @@
from webbrowser import get
from click import style
from utils.console import print_markdown, print_step, print_substep from utils.console import print_markdown, print_step, print_substep
import praw import praw
import random import random
@ -34,12 +37,12 @@ def get_subreddit_threads():
username=os.getenv("REDDIT_USERNAME"), username=os.getenv("REDDIT_USERNAME"),
password=passkey, password=passkey,
) )
# If the user inserts a thread link, pick that one # If the user specifies that he doesnt want a random thread, or if he doesn't insert the "RANDOM_THREAD" variable at all, ask the thread link
if os.getenv("THREAD_LINK"): if not os.getenv("RANDOM_THREAD") or os.getenv("RANDOM_THREAD") == "no":
print_substep("Insert the full thread link:", style="bold green")
thread_link = input()
print_step(f"Getting the inserted thread...") print_step(f"Getting the inserted thread...")
thread_id = thread_link.split("/")[6]
thread_id = os.getenv("THREAD_LINK").split("/")[6]
submission = reddit.submission(thread_id) submission = reddit.submission(thread_id)
else: else:
# Otherwise, picks a random thread from the inserted subreddit # Otherwise, picks a random thread from the inserted subreddit

Loading…
Cancel
Save