Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sub = '123'
- #########################################################################
- #########################################################################
- #Poll Reddit by sub
- subReddit = reddit.subreddit(sub)
- # returns link templates on specified subreddit
- flair_template = subReddit.flair.link_templates
- flair_list = [flair['id'] for flair in flair_template]
- flair_list_text = [flair['text'] for flair in flair_template]
- print ('\n\n*' + '{:^78}'.format('****** STARTing flairUP ******') + '*\n\n')
- print(flair_list_text)
- print(flair_list)
- #Iterate thru the results
- for submission in subReddit.search('flair:"321"', sort='new', limit=999):
- print(submission.title)
- #Checks if flair attribute exists, sets None if doesn't and assigns to temp var
- ##AutoMod Flairs have no link flair template id attribute
- linkFlairTemplateID = getattr(submission, 'link_flair_template_id', None)
- #Checks post flair template id against sub flair template id list
- if linkFlairTemplateID not in flair_list:
- print('-------- negative flair template match')
- else:
- print(linkFlairTemplateID)
- submission.flair.select(linkFlairTemplateID)
- print ('\n\n' + '{:^80}'.format('******* FINISHED *******') + '\n\n')
Advertisement
Add Comment
Please, Sign In to add comment