import flickrapi | |
import urllib | |
import json | |
import random | |
import filecmp | |
import shutil | |
import os.path | |
from pprint import pprint | |
api_key = u'your api key' | |
api_secret = u'your api secret' | |
access_token = u'xxxxxxxxxxxxxxxxxx-xxxxxxxxxxxx' # these two get filled in in a bit | |
token_secret = u'xxxxxxxxxxxxx' | |
user_id = "your user id" # mine was 48889036627@N01 | |
flickr = flickrapi.FlickrAPI(api_key, api_secret,format='parsed-json') | |
photos = [] | |
print('Step 1: authenticate') | |
# Only do this if we don't have a valid token already | |
if not flickr.token_valid(perms='read'): | |
# Get a request token | |
flickr.get_request_token(oauth_callback='oob') | |
# Open a browser at the authentication URL. Do this however | |
# you want, as long as the user visits that URL. | |
authorize_url = flickr.auth_url(perms=u'read') | |
print(authorize_url) | |
# Get the verifier code from the user. Do this however you | |
# want, as long as the user gives the application the code. | |
verifier = unicode(raw_input('Verifier code: ')) | |
# Trade the request token for an access token | |
flickr.get_access_token(verifier) | |
print('Step 2: use Flickr') | |
for x in range(1, 8): # the number is in the response - I just ran out of time to handle it! | |
resp = flickr.favorites.getList(api_key=api_key,user_id=user_id,per_page='500',authenticated=True,page=x,extras="description,date_upload,date_taken,owner_name,icon_server,original_format,last_update,geo,tags,machine_tags,o_dims,views,media,path_alias,url_sq,url_t,url_s,url_q,url_m,url_n,url_z,url_c,url_l,url_o") | |
# print(json.dumps(resp, indent=4)) | |
filen = "faves_"+str(x)+".json" | |
print("dumping faves to "+filen) | |
file = open(filen,"w") | |
file.write(json.dumps(resp, indent=4)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment