Flickr Sync
This code provides a Django model for photos based on Flickr, as well as a script to perform a one-way sync between Flickr and a Django installation. *Please note that the snipped contains code for two files, update.py and a Django model.* *The two chunks are separated by:* """ END OF FLICKRUPDATE """ """ START DJANGO PHOTO MODEL Requires django-tagging (http://code.google.com/p/django-tagging/) """ My model implements tagging in the form of the wonderful django-tagging app by Jonathan Buchanan, so be sure to install it before trying to use my model. The flickrupdate.py code uses a modified version of flickerlib.py (http://code.google.com/p/flickrlib/). Flickr returns invalid XML occasionally, which Python won't stand for. I got around this by wrapping the return XML in `<flickr_root>` tags. To modify flickrlib to work with my code, simply change the this line: return self.parseData(getattr(self._serverProxy, '.'.join(n))(kwargs)) to: return self.parseData('<flickr_root>' + getattr(self._serverProxy, '.'.join(n))(kwargs) + '</flickr_root>') I hate this workaround, but I can't control what Flickr returns. flickrupdate will hadle the addition and deletion of photos, sets and tags. It will also keep track of photos' pools, although, right now, it doesn't delete unused pools. This is mostly because I don't care about unused pools hanging around. It's a simple enough addition, so I'll probably add it when I have a need. Be sure to set the appropriate information on these lines: api_key = "YOUR API KEY" api_secret = "YOUR FLICKR SECRET" flickr_uid = 'YOUR FLICKR USER ID' I hadn't seen a Django model and syncing script, so I threw these together. I hope they will be useful to those wanting start syncing their photos.
- flickr
- photos
- photo
- flicker