# -*- coding: utf-8 -*-

from browshot import BrowshotClient

browshot = BrowshotClient('my_api_key')


# You can only host screenshots in finished state
list = browshot.screenshot_list({ 'limit': 1, 'status': 'finished' })

if len(list) == 0:
	print "No screenshot finished"
else:
  id = 0
  for key, screenshot in list.iteritems():
    id = key
  
  result = browshot.screenshot_host(id, {
    'hosting': 's3', 
    'bucket': 'my_bucket', 
    'file': 'youtube.png', 
    'width': 600
  }) # host a thumbnail
  
  if result['status'] == 'ok':
    print "The screenshot is now hosted at %s" % result['url']
  else:
    print "hosting failed: %s" % result['error']