Created
April 30, 2015 15:41
-
-
Save henningpohl/6ad75e6ffb0625753cfd to your computer and use it in GitHub Desktop.
Download original files of photos in a flickr photoset
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib | |
import os | |
import flickrapi | |
api_key = "" | |
api_secret = "" | |
def download_set(user_id, set_id): | |
flickr = flickrapi.FlickrAPI(api_key, api_secret, format='parsed-json', cache=True) | |
photos = flickr.photosets.getPhotos(user_id=user_id, photoset_id=set_id) | |
for i, photo in enumerate(photos['photoset']['photo']): | |
sizes = flickr.photos.getSizes(photo_id=photo['id'])['sizes']['size'] | |
original = [s for s in sizes if s['label'] == "Original"][0] | |
filename = "%s.jpg" % photo['title'] | |
if os.path.exists(filename) == False: | |
print "downloading", filename | |
urllib.urlretrieve (original['source'], filename) | |
if __name__ == '__main__': | |
download_set("user-id", "set-id") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment