def process(): c = 0 subreddits = ["showerthoughts", "themonkeyspaw"] print("0. shower thoughts \n1. the monkeys paw") subreddit = subreddits[int(input("Enter subreddit: "))] reddit_obj = reddit.reddit() imgur_obj = imgur.imgur() create_iamge_obj = create_iamge.create_image() reddit_obj.reddit_init(subreddit) imgur_obj.imgur_init() title = reddit_obj.get_post() for i in title: print(f"{c}: {i.title}") c += 1 post_index = (input("Which one: ")).split(",") post_index = list(map(lambda x: int(x), post_index)) for x_position in post_index: title1 = title_process(title[x_position].title) # print(title) create_iamge_obj.create_image_and_save(title1, subreddit) imgur_obj.upload_fking_image()
# Check if the room is dark hist = cv.CreateHist([32], cv.CV_HIST_ARRAY, [[0, 255]], 1) cv.CalcHist([bwimg], hist, 0, None) hist_img = cv.CreateImage((32*10,255), 8, 3) (_,max_value,_,_) = cv.GetMinMaxHistValue(hist) (sizex, sizey) = cv.GetSize(bwimg) darkcount = 0 for i in range(8): darkcount = darkcount + cv.QueryHistValue_1D(hist, i) if darkcount > (.7 * (sizex * sizey)): print "Image is dark. Not sending data." else: print "Image is light. Sending data." if len(faces) > 0: try: imgapi = imgur.imgur(apikey=imgur_api_key) imgurl = imgapi.upload(stamp+".jpg") api = twitter.Api(username=twitter_user, password=twitter_pass) status = api.PostUpdate(tweet+" "+imgurl['rsp']['image']['original_image']) except: print "Failed!" # Clean up our mess os.remove(source)
""" import os import sys import time import yaml import imgur import reddit import db_interface #Work out where we are DIR = os.path.dirname(os.path.realpath(__file__)) #Get the config conf = yaml.safe_load(open("{}/A858_image.cfg".format(DIR))) r = reddit.reddit(conf) i = imgur.imgur(conf) def run(conf, r, i): print "# Imagerator running #" p, e, s = 0, 0, 0 sym = '\\' sym = updateCLI(sym,p,e,s) mostRecent = None while True: processed = 0 # get the sub subreddit = r.get_subreddit('A858DE45F56D9BC9') # if we've just started let's start from the begining, otherwise we'll pick up where we left off