/insta_reddit

Download posts from a subreddit

Primary LanguagePythonMIT LicenseMIT

insta_reddit

insta_reddit flow

  1. Download top K posts from a subreddit (chosen r/unethicallifeprotips for this).
  2. Generate an image out of those posts.
  3. Generate a caption for those posts.
  4. Upload them to an Instagram account.

Installation

Setting up credentials

  1. Get PRAW credentials from Reddit.
  2. Setup a service account to use Google Sheets as a DB.
  3. Download the service account JSON from the step above and add it to your repo. Use the screenshot below for reference.

At the end of all the setup, the credentials file should look like this: credentials

Support modules

Install requirements by running:

pip install -r requirements.txt

Link to install the "arial.ttf" font if you need it. You'll also need nltk, used to generate captions. Run the following (one-time effort) from a Python3 shell.

import nltk
nltk.download("punkt")
nltk.download('averaged_perceptron_tagger')
nltk.download('wordnet')

For SSL issues at this stage, run bash /Applications/Python 3.6/Install Certificates.command

How to run the entire thing:

cd insta_reddit/code
python download_from_reddit.py
python draw_text_on_image.py
python upload_to_instagram.py

Or run the modifiable Cron job (remember to change the venv path):

sh run_all_jobs.sh

Or add the above to your crontab to run at your set frequency:

crontab -e

Add this line your crontab: @daily /path/to/run_all_jobs.sh

End result on Instagram:

feed

Sample post: sample_post

Contributing

Pull requests are welcome! For major changes, please open an issue first to discuss what you would like to change.

Author

  • Surya Shekhar Chakraborty

Much thanks to Avishek Rakshit for help with the graphic design, Puneet Jindal for brainstorming, and to you for coming here. :)

License

This project is licensed under the MIT License - see the LICENSE file for details