2012-02-06 13:02:20 +00:00
|
|
|
import json
|
|
|
|
from os.path import expanduser
|
|
|
|
|
2012-02-06 03:49:57 +00:00
|
|
|
import flickrapi
|
|
|
|
|
|
|
|
|
2012-02-06 13:02:20 +00:00
|
|
|
def setup_flickr(api_key, api_secret):
|
|
|
|
flickr = flickrapi.FlickrAPI(api_key, api_secret)
|
2012-02-06 03:49:57 +00:00
|
|
|
|
2012-02-06 13:02:20 +00:00
|
|
|
token, frob = flickr.get_token_part_one(perms='write')
|
2012-02-06 03:49:57 +00:00
|
|
|
if not token:
|
|
|
|
raw_input("Press ENTER after you authorized this program")
|
|
|
|
|
2012-02-06 13:02:20 +00:00
|
|
|
flickr.get_token_part_two((token, frob))
|
|
|
|
return flickr
|
|
|
|
|
|
|
|
|
|
|
|
def get_flickr_from_rc_file(rc_file=expanduser('~/.flickrscripts.json')):
|
|
|
|
rc_conf = json.load(open(rc_file))
|
|
|
|
return setup_flickr(rc_conf['APIKEY'], rc_conf['APISECRET'])
|