sigizmund.com
flickrpy + 30 lines of code = poor man's Flickr Backup solution
By sigizmund On January 15, 2010 · 235 Commentshttp%3A%2F%2Fsigizmund.com%2Fflickrpy-30-lines-of-code-poor-mans-flickr-backup-solution%2Fflickrpy+%2B+30+lines+of+code+%3D+poor+man%26%23039%3Bs+Flickr+Backup+solution2010-01-15+12%3A11%3A00sigizmundhttp%3A%2F%2Fsigizmund.wordpress.com%2F2010%2F01%2F15%2Fflickrpy-30-lines-of-code-poor-mans-flickr-backup-solution
It uses somewhat buggy but excellent flickrpy module by James Clarke — works well for me after some small adjustments:
def main(): flickr.API_KEY = constants.API_KEY flickr.API_SECRET = constants.API_SECRET u = flickr.User(id = '92002612@N00') sets = u.getPhotosets() for ps in sets: name = ps.title name = name.replace('"', "'").replace("/", "_") folderName = "/Users/kirillov/Pictures/Flickr/%s" % name if os.path.exists(folderName): print("Path exists, skipping: %s" % folderName ) continue photos = ps.getPhotos() os.mkdir(folderName) i = 0 for i,p in enumerate(photos): src = p.getSizes()[-1]['source'] photoname = p.getTitle().replace("/", "_") fname = '/Users/kirillov/Pictures/Flickr/%s/%s-%d.jpg' % (name, photoname, i) data = u2.urlopen(src).read() open(fname, 'w').write(data) print('%s => "/Users/kirillov/Pictures/Flickr/%s/%s-%d.jpg"' % (src,name, photoname, i))
Upd: fixed and updated version posted.
5 Responses to flickrpy + 30 lines of code = poor man's Flickr Backup solution
Leave a Reply Cancel reply
-
Categories
-
Calendar
February 2012 M T W T F S S « Jun 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 -
Meta





Nice!
Do you know about enumerate?Get rid of the ‘i’ variable and just sayfor i, p in enumerate(photos):Are you sure you won’t have a slash (‘/’) in your names that would need replacing?
@Holger: good point about slashes. Not likely but still. W.r.t to enumerate — nope, didn’t think about it :-) anyway let’s wait till it fails, then I will write a work around for not re-downloading already downloaded sets, escaping slashes and fixing whatever-problem-it-will-fail-because-of.
Finally it's failed – slash in the name, as it was expected. Fixing the script…
Yeah, script is fixed and running on :-) still buggy probably, but at least file name “????? ???????? ? ?????????? ? Mac OS X / Apple / ?????????.jpg” doesn’t confuse it anymore.