Guest User

Untitled

a guest
Jul 20th, 2022
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.23 KB | None | 0 0
  1. sub = '123'
  2.  
  3. #########################################################################
  4. #########################################################################
  5.  
  6. #Poll Reddit by sub
  7. subReddit = reddit.subreddit(sub)
  8.  
  9. # returns link templates on specified subreddit
  10. flair_template = subReddit.flair.link_templates
  11.  
  12. flair_list = [flair['id'] for flair in flair_template]
  13. flair_list_text = [flair['text'] for flair in flair_template]
  14.  
  15. print ('\n\n*' + '{:^78}'.format('******  STARTing flairUP  ******') + '*\n\n')
  16. print(flair_list_text)
  17. print(flair_list)
  18.  
  19. #Iterate thru the results
  20. for submission in subReddit.search('flair:"321"', sort='new', limit=999):
  21.   print(submission.title)
  22.   #Checks if flair attribute exists, sets None if doesn't and assigns to temp var
  23.   ##AutoMod Flairs have no link flair template id attribute
  24.   linkFlairTemplateID = getattr(submission, 'link_flair_template_id', None)
  25.   #Checks post flair template id against sub flair template id list
  26.   if linkFlairTemplateID not in flair_list:  
  27.     print('-------- negative flair template match')
  28.   else:
  29.     print(linkFlairTemplateID)
  30.     submission.flair.select(linkFlairTemplateID)
  31.  
  32. print ('\n\n' + '{:^80}'.format('*******  FINISHED  *******') + '\n\n')
Advertisement
Add Comment
Please, Sign In to add comment