Created
March 16, 2010 10:19
-
-
Save evaisse/333820 to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/python | |
"""Usage: python flickrset2backup.py api_key photoset_id /path/to/backup/folder | |
find your set id in the set url | |
http://www.flickr.com/photos/evaisse/sets/72157602716593936/ | |
get userid with idgetr http://idgettr.com/ | |
ex : ./flickrset2backup.py 4c2f9a5259c09c04c2fcd2a7 \ | |
72157602716593936 ./backup | |
""" | |
__author__ = "Emmanuel Vaisse <evaisse@gmail.com>" | |
__version__ = "$Rev$" | |
__date__ = "$Date$" | |
import sys | |
import flickrapi | |
import urllib | |
def main(*argv): | |
from getopt import getopt, GetoptError | |
if ( len(argv) < 3 ): | |
print __doc__ | |
return 1 | |
api_key = argv[1] | |
photosetid = argv[2] | |
backup_path = argv[3] | |
print photosetid | |
flickr = flickrapi.FlickrAPI(api_key, format='etree') | |
photos = flickr.photosets_getPhotos(photoset_id=photosetid).find('photoset') | |
for photo in photos: | |
id = photo.attrib['id'] | |
photo = flickr.photos_getSizes(photo_id=photo.attrib['id']).find('sizes') | |
for size in photo: | |
source = size.attrib['source'] | |
print 'retrieve %s' % (source) | |
urllib.urlretrieve( source, backup_path + '/' + id + "flickr.jpg") | |
return 0 | |
if __name__ == '__main__': | |
sys.exit(main(*sys.argv)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment