@ -19,9 +19,7 @@ def get_subreddit_threads(POST_ID: str):
content = { }
content = { }
if settings . config [ " reddit " ] [ " creds " ] [ " 2fa " ] :
if settings . config [ " reddit " ] [ " creds " ] [ " 2fa " ] :
print (
print ( " \n Enter your two-factor authentication code from your authenticator app. \n " )
" \n Enter your two-factor authentication code from your authenticator app. \n "
)
code = input ( " > " )
code = input ( " > " )
print ( )
print ( )
pw = settings . config [ " reddit " ] [ " creds " ] [ " password " ]
pw = settings . config [ " reddit " ] [ " creds " ] [ " password " ]
@ -47,9 +45,7 @@ def get_subreddit_threads(POST_ID: str):
] : # 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 (
re . sub ( r " r \ / " , " " , input ( " What subreddit would you like to pull from? " ) )
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 :
@ -59,9 +55,7 @@ def get_subreddit_threads(POST_ID: str):
sub = settings . config [ " reddit " ] [ " thread " ] [ " subreddit " ]
sub = settings . config [ " reddit " ] [ " thread " ] [ " subreddit " ]
print_substep ( f " Using subreddit: r/ { sub } from TOML config " )
print_substep ( f " Using subreddit: r/ { sub } from TOML config " )
subreddit_choice = sub
subreddit_choice = sub
if (
if ( str ( subreddit_choice ) . casefold ( ) . startswith ( " r/ " ) ) : # removes the r/ from the input
str ( subreddit_choice ) . casefold ( ) . startswith ( " r/ " )
) : # removes the r/ from the input
subreddit_choice = subreddit_choice [ 2 : ]
subreddit_choice = subreddit_choice [ 2 : ]
subreddit = reddit . subreddit (
subreddit = reddit . subreddit (
subreddit_choice
subreddit_choice
@ -73,9 +67,7 @@ def get_subreddit_threads(POST_ID: str):
settings . config [ " reddit " ] [ " thread " ] [ " post_id " ]
settings . config [ " reddit " ] [ " thread " ] [ " post_id " ]
and len ( str ( settings . config [ " reddit " ] [ " thread " ] [ " post_id " ] ) . split ( " + " ) ) == 1
and len ( str ( settings . config [ " reddit " ] [ " thread " ] [ " post_id " ] ) . split ( " + " ) ) == 1
) :
) :
submission = reddit . submission (
submission = reddit . submission ( id = settings . config [ " reddit " ] [ " thread " ] [ " post_id " ] )
id = settings . config [ " reddit " ] [ " thread " ] [ " post_id " ]
)
else :
else :
threads = subreddit . hot ( limit = 25 )
threads = subreddit . hot ( limit = 25 )
submission = get_subreddit_undone ( threads , subreddit )
submission = get_subreddit_undone ( threads , subreddit )