'PRAW Posting new submission with a flair?
Trying to post to a subreddit that requires flairs
reddit.subreddit('test').submit(title,url=link,flair_id='')
i didn't know how to find the flair_id of a subreddit ?
also when I try to share an image with praw using
Trying to post to a subreddit that requires flairs
reddit.subreddit('').submit_image(title,image_path=image,flair_id='')
how should i write the image path ?
Solution 1:[1]
You can find the available flair ids with
reddit.subreddit("test").flair.templates
The image path is a path relative to the script
ex.
script/
- main.py
- image.png
reddit.subreddit('').submit_image(title, image_path="image.png")
Solution 2:[2]
The info to print flair_id can be found here
template_info = list(subreddit.flair.templates)[0]
subreddit.flair.templates.update(
template_info["id"],
text=template_info["flair_text"],
text_editable=True,
)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | MiranDaniel |
Solution 2 | Andy Kim |