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=""
# Link of the thread
# (e.g. https://www.reddit.com/r/memes/comments/sbr31o/discordggrmemes_the_official_rmemes_discord_server/)
THREAD_LINK=""
#If no, it will ask you a thread link to extract the thread, if yes it will randomize it.
RANDOM_THREAD="no"

@ -1,3 +1,6 @@
from webbrowser import get
from click import style
from utils.console import print_markdown, print_step, print_substep
import praw
import random
@ -34,12 +37,12 @@ def get_subreddit_threads():
username=os.getenv("REDDIT_USERNAME"),
password=passkey,
)
# If the user inserts a thread link, pick that one
if os.getenv("THREAD_LINK"):
# 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 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...")
thread_id = os.getenv("THREAD_LINK").split("/")[6]
thread_id = thread_link.split("/")[6]
submission = reddit.submission(thread_id)
else:
# Otherwise, picks a random thread from the inserted subreddit

Loading…
Cancel
Save