示例#1
0
def tweetElPais():
    # current date and time
    now = datetime.now()

    # date of front page
    year = str(int(now.strftime("%Y")) - TIME_BACK)
    month = now.strftime("%m")
    day = now.strftime("%d")

    # Path where image will be stored
    image_path = os.path.join(PORTADA_PATH, 'elpais' + year + month + day)

    # Download image
    retrieveImage(year, month, day, image_path)

    # Tweet text
    tweet_text = 'El Pais ' + day + '/' + month + '/' + year

    # Tweet
    for attempt in range(300):
        try:
            twitter.sendTweet(tweet_text, image_path + '.jpg')
        except:
            print('Error to tweet El Pais, attempt {}'.format(attempt + 1))
            time.sleep(10)
        else:
            break

    # Delete image and pdf
    os.remove(image_path + '.jpg')

    # Print progress
    print(year + '/' + month + '/' + day + ' El Pais: Completado')
示例#2
0
def main():
    title = searchForTMNT(MAX_ATTEMPTS, BACKOFF)
    logo = images.getLogo(words.addPadding(title))
    status_text = "\n".join((title, words.getWikiUrl(title)))

    if len(status_text) > MAX_STATUS_LEN:
        status_text = title

    _ = twitter.sendTweet(status_text, logo)
    _ = mastodon.sendToot(status_text, logo)
示例#3
0
def main():
    api = twitter.createClient()
    me = api.me()
    print(f"Logged in with {me.name} (@{me.screen_name})")
    while True:
        syllables = searchForLick(MAX_ATTEMPTS, BACKOFF)
        score = images.getLiccScore(syllables)
        with tempfile.NamedTemporaryFile(suffix=".png") as file:
            score.save(file)
            _ = twitter.sendTweet(api, file)
        print("Tweet was posted.")
        print(f"Waiting {POST_PERIOD}s until next post")
        time.sleep(POST_PERIOD)
示例#4
0
def main():
    print(f"[{datetime.now()}] Start")
    title = searchForTMNT(MAX_ATTEMPTS, BACKOFF)
    logo = images.getLogo(words.addPadding(title))
    status_text = "\n".join((title, words.getWikiUrl(title)))

    if len(status_text) > MAX_STATUS_LEN:
        status_text = title

    _ = twitter.sendTweet(status_text, logo)
    _ = mastodon.sendToot(status_text, logo)

    os.remove(logo)
    print(f"[{datetime.now()}] Complete! Posted: {title}\n=====")
示例#5
0
def main():
    syllables = searchForLick(MAX_ATTEMPTS, BACKOFF)
    score = images.getLiccScore(syllables)
    path = f"./temp/licc-{int(time.time())}.png"
    score.save(path)
    _ = twitter.sendTweet(path)