forked from LindseyB/starwars-dot-gif
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tumblr_bot.py
39 lines (29 loc) · 980 Bytes
/
tumblr_bot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import random
import os
import ConfigParser
import time
from tumblpy import Tumblpy
from makeGifs import makeGif
config = ConfigParser.ConfigParser()
config.read("config.cfg")
config.sections()
CONSUMER_KEY = config.get("tumblr", "consumer_key")
CONSUMER_SECRET = config.get("tumblr", "consumer_secret")
OAUTH_TOKEN = config.get("tumblr", "oauth_token")
OAUTH_TOKEN_SECRET = config.get("tumblr", "oauth_token_secret")
t = Tumblpy(
CONSUMER_KEY,
CONSUMER_SECRET,
OAUTH_TOKEN,
OAUTH_TOKEN_SECRET,
)
while True:
quote = makeGif(random.randint(4,6), 0, rand=True)
quote = ' '.join(quote)
while(os.path.getsize('star_wars.gif') > 1048576):
os.popen('convert star_wars.gif -resize 90% star_wars.gif')
photo = open('star_wars.gif', 'rb')
post = t.post('post', blog_url='http://starwarsgifsasaservice.tumblr.com', params={'type':'photo', 'caption': quote, 'data': photo, 'tags': 'star wars, gif'})
print "sleeping..."
# sleep 12 hours
time.sleep(43200)