How to Set up Automatic Random Posts With Python, Schedule, & Beempy!

in #python5 years ago (edited)

Screen Shot 2019-08-31 at 3.36.26 PM.png

I simply used the Python Schedule API to run my Beempy random image script on a timer!

I just set @honusurf to post a random image post once every 10 minutes, I am writing this post while I wait with my fingers crossed, and it worked. Don't worry, I won't leave it on forever, just shifts. I will set the timer to every 6 hours possibly?? What do you think?? I don't want repeats, at least too many so I still need to feed the machine with my original pics, housekeeping/ bot maintenance is still a lotta work!

Here's the script:



#!/usr/local/bin/python3
from beem.imageuploader import ImageUploader
from beem import Steem
import random, os
import schedule
import time

def job():
if name == "main":
stm = Steem()
author = "honusurf"
path = "/Users/nick/random-surf"
random_filename = random.choice([
x for x in os.listdir(path)
if os.path.isfile(os.path.join(path, x))
])
image_path = random_filename
image_uploader = ImageUploader(steem_instance=stm)
img_link = image_uploader.upload(image_path, author, image_name="@honusurf:)")

    title = "Random SURF by @honusurf!!"

    body = "Original Maui Surf Pics by @honusurf. "\
           "Random photo uploaded with beempy image:![x]("\
           "%s" % img_link["url"]
    parse_body = True
    self_vote = False
    tags = ["honu", "photo", "original", "maui", "beem", "bot", "post"]
    stm.post(title, body, author=author, tags=tags, parse_body=parse_body, self_vote=self_vote)

schedule.every(10).minutes.do(job)
while True:
schedule.run_pending()
time.sleep(1)


This little script is helpful, I just launched it and @honusurf already did one post on it's own! = Success! = Makes my life easier!

There's still a lot I need to do to make the script better. I.E. delete image after posting so I don't get repeats!! The image folder is just used organize the groups, and the beempy still reads the images from the home directory, so that could be tweaked a bit. I also need to throw the hyperlink in to the large image! Also optimizing my image, getting AI to comment on the image and describe it, lol! Tons of work too do! If anyone has any suggestions and or additions please post in the comments below!

Screen Shot 2019-08-31 at 3.51.18 PM.png

Screen Shot 2019-08-31 at 3.53.19 PM.png

Screen Shot 2019-08-31 at 4.12.16 PM.png

Then I had to shut it down!

All tests worked out well, now for adding some more images and getting this set up for my other accounts! Wow I really like this Python stuff a lot!
Screen Shot 2019-08-31 at 4.24.41 PM.png

Screen Shot 2019-08-31 at 4.24.24 PM.png

Follow @coininstant for more!

Sort:  

Hmmm ...HEy I just say it .. you user name comments I not see here in steemit , but when I use esteem surfer then this takes them open and lets me see it what you text .

Oh yeah that is because I got my comments stricken from the posts! To see my conversations you have to know where to find them.

OK ..ok :)
And how is day there? ... I hope sun is up and strong . :)

Actually it is just night time right now out here, sun just set about an hour ago, it was so rainy & clouded in I could not get a pic.

Here soon winter back and also lot times very rainy ... this how here summer ends :)

I really need to look into Python

Posted using Partiko Android

How I wish I could do coding!
My brain is too slow!
Perhaps I should go to some classes.

You are a genius to be able to code like that!
Have a nice weekend!

Coin Marketplace

STEEM 0.28
TRX 0.28
JST 0.047
BTC 95519.24
ETH 3581.62
SBD 3.68