10 Inspired Thoughts #28daysofcode #python

code Aug 04, 2018

Exciting times today!

This script is a combination of days 2,3,5,6,7,8, and 9 of the 28 days of code. Needless to say it has taken a long time to complete. In honor of that i created my own subreddit where future posts from this script will show up. I plan on running this script as a cron job 2-4 times a day. Then downvote the bad ones.

Link to subreddit

You can run the script yourself, just need to sign up for API keys on Unsplash, Twitter, Reddit, Imgur, and Algorithmia.

I am super excited about the Algorithmia integration as it provides sentiment analysis for the Shower Thought provided.


shower thought to image Creator

  • Grab random /r/showerthoughts, then grab random pic from unsplash
  • Merge text and pic, upload to imgur
  • post to Reddit /r/inspiredthoughts
  • post to Twitter


API keys, API keys, API keys!

You will need to get keys for Twitter, Imgur, Reddit, Algorithmia, and Unsplash.

Luckily the previous days of the month we've already gathered the needed keys. Add them to the config.py

You should have all the modules needed in your virtualenv as we've been installing them along the way.
If not pull them in via the requirements.txt file in the root of this repo.

pip install -r requirements.txt

The App

Link to app repo on Github:

10 git repo


Run it:

python inspiredthoughts.py


python inspiredthoughts.py 
Got image info and download.
Inspired Thought Image Created.
Posted to Imgur: https://i.imgur.com/40A6xwr.jpg
Posted to reddit.
Posted tweet
removed main image.
removed tweepy image.
removed imgur image.
removed inspired thought image.
Removed all local files

note: there is a small json file left over with image info.

This was the first working product of inspiredthoughts.py

python inspiredthoughts.py 
downloaded image to disk.
{'author': 'EddiOS42', 'url': 'https://www.reddit.com/r/Showerthoughts/comments/7wjiqc/bench_presses_are_so_much_less_confusing_when_the/', 'showerthought': 'Bench presses are so much less confusing when the bar aligns with the seams of the ceiling panels.', 'topic': 'clouds', 'sentiment_number': -0.2193, 'image_name': 'sqKJxvLue3Q', 'image_url': 'https://images.unsplash.com/photo-1473182446278-fa0683411d10?ixlib=rb-0.3.5&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=1080&fit=max&ixid=eyJhcHBfaWQiOjIzMDJ9&s=9e97cea0bb1bec25d5afda0801c5120f', 'image_photographer': 'cservay', 'image_photographer_profile_url': 'https://unsplash.com/@cservay', 'image_file_name': 'image_sqKJxvLue3Q.jpeg'}
Got image info and download.

sorry for the HUGE download, this was before I trimmed the images

working image


Utopia Machine

Enthusiastic highly imaginative senior technologist with creative approaches to solving problems