Example #1
0
def solve_tweeted_set(tweet_url, with_sets_outlined=True):
    tweet_content = requests.get(tweet_url).content

    # scrape tweet HTML string for image url
    soup = BeautifulSoup(tweet_content, 'lxml')
    img_url = soup.find('meta', attrs={'property': 'og:image'})['content']
    #print img_url

    # find Sets
    kwargs = {'path_is_url': True, 'pop_open': False}
    kwargs['draw_contours'] = (True if with_sets_outlined else False)
    kwargs['sets_or_no'] = (False if with_sets_outlined else True)
    #print "about to play"
    num_sets, initial_img_str = t.play_game(img_url, **kwargs)
    #print num_sets

    # send string with media_data (rather than media) tag because it is base64 encoded
    img_str = 'media_data={}'.format(initial_img_str)

    text = ("Whoa! {} sets #craycray".format(num_sets) if num_sets \
           else "No sets #bummer #sadface")

    img_str = (img_str if num_sets else None)

    return (text, img_str)
Example #2
0
def solve_uploaded_set(image_url):
    kwargs = {"pop_open": False, "save_image": True, "output_dir": app.config["OUTPUT_FOLDER"]}

    return tests.play_game(image_url, **kwargs)