Post to Tumblr with python

Last Update: 19.05.2013. By azarai in python

I have an art blog over at tumblr where i post my (almost) daily doodles. Usually i post them with the Tumblr UI, but lately i i got annoyed but that way and hacked something together to post images directly from my windows exlorer.

  1. Register an app at tumblr
  2. Install oauth2 and pytumblr
  3. Modify the “Twitter Three-legged OAuth Example” Script from python-oauth2 to use tumblr endpoints and insert your consumer key and secret
  4. Run the script and note the oauth token and secret the script outputs
  5. My actual Poster Script (pretty less coe :-) ), add your keys and blog url here

    import pytumblr
    import sys
    
    client = pytumblr.TumblrRestClient(
        '<consumer_key>',
        '<consumer_secret>',
        '<oauth_token>',
        '<oauth_secret>',
    )
    
    client.create_photo("your blog url", state="published" , data=sys.argv[1])
    
  6. Add Script to Windows Explorer context menu follwoing this tutorial

    <path-to-python>python.exe <path_to_script>poster.py "%1"
    
  7. Enjoy :-)