A "set-it-and-forget-it" Python program to handle automation of media posts to Reddit from a directory of files on the host machine.
The core of this program is the Scheduler object, which is constructed with a pathlib.Path
, a list of Subreddits, and an Imgur API Client ID. When a scheduler object's make_posts()
method is called, it will:
- Select a photo randomly from the directory
- Log the filename to
log/log.txt
- Upload the image to Imgur anonymously
- Submit the Imgur link to each Subreddit in the list
- Log each submission's permalink to
log/links.txt
This will create a scheduler object that looks in the directory /Users/chris/Pics/Dir-Of-Photos/
and post it to the subs ['sub_1', 'sub_2', 'sub_3', 'sub_4']
.
from pathlib import Path
s = scheduler.Scheduler(
Path('/Users/chris/Pics/Dir-Of-Photos'),
['sub_1', 'sub_2', 'sub_3', 'sub_4'],
'imgur_client_id'
)
s.make_posts()
- Clone this repo
cd
to the folderpython3.7 -m venv venv
- Activate your virtual environment
python setup.py develop
pip install -r requirements.txt
To "set-it-and-forget-it," install the package on a machine that is always online (i.e. a VPS or even a Raspberry Pi on your network) and use cron
:
0 12 * * * cd Projects/reddit-folder-post-scheduler/ && . venv/bin/activate && python scripts/script.py
- Imgur API Client registration: https://api.imgur.com/oauth2/addclient
- PRAW Docs: https://praw.readthedocs.io/en/latest/