Created
March 11, 2009 06:03
-
-
Save jyr/77342 to your computer and use it in GitHub Desktop.
wrapper tumblr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from tumblr import Api | |
import tumblr | |
import urllib2 | |
import sys | |
errors = { | |
‘403’:”Login o password incorrectos”, | |
‘404’: “Tumblrblog incorrecto”, | |
‘urlopen’ : “no ingreso su tumblrblog” | |
} | |
BLOG= ” | |
USER=’tumail’ | |
PASSWORD=’tupassword’ | |
if len(sys.argv) != 3: | |
print “Usage: ‘EL TITULO’ ‘EL CUERPO’” | |
sys.exit(-1) | |
title = sys.argv[1] | |
body = sys.argv[2] | |
api = Api(BLOG, USER,PASSWORD) | |
try: | |
post = api.write_regular(title,body) | |
print “Published: “, post[‘url’] | |
except tumblr.TumblrAuthError: | |
print errors[‘403’] | |
except urllib2.HTTPError: | |
print errors[‘404’] | |
except urllib2.URLError: | |
print errors[‘urlopen’] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment