Skip to content

Instantly share code, notes, and snippets.

@jyr
Created March 11, 2009 06:03
Show Gist options
  • Save jyr/77342 to your computer and use it in GitHub Desktop.
Save jyr/77342 to your computer and use it in GitHub Desktop.
wrapper tumblr
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