Changes between Version 3 and Version 4 of FlickrIntegration
- Timestamp:
- Nov 20, 2006, 10:23:14 AM (18 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
FlickrIntegration
v3 v4 77 77 #!python 78 78 def sync_flickr_photos(*args, **kwargs): 79 API_KEY = ' your_api_key_here'80 USER_ID = ' your_id_here'81 79 API_KEY = 'INSERT API KEY' 80 USER_ID = 'INSERT USER ID' 81 82 82 cur_page = 1 # Start on the first page of the stream 83 83 paginate_by = 20 # Get 20 photos at a time 84 84 dupe = False # Set our dupe flag for the following loop 85 85 86 86 client = FlickrClient(API_KEY) # Get our flickr client running 87 87 88 88 while (not dupe): 89 89 photos = client.flickr_people_getPublicPhotos(user_id=USER_ID, page=cur_page, per_page=paginate_by) 90 90 91 91 for photo in photos: 92 92 try: 93 row = Photo.objects.get(flickr_id=photo("id"), flickr_secret= photo("secret"))93 row = Photo.objects.get(flickr_id=photo("id"), flickr_secret=str(photo("secret"))) 94 94 # Raise exception if photo doesn't exist in our DB yet 95 95 96 96 # If the row exists already, set the dupe flag 97 97 dupe = True 98 98 except ObjectDoesNotExist: 99 99 p = Photo( 100 title = photo("title"),101 flickr_id = photo("id"),102 flickr_owner = photo("owner"),103 flickr_server = photo("server"),104 flickr_secret = photo("secret")100 title = str(photo("title")), 101 flickr_id = int(photo("id")), 102 flickr_owner = str(photo("owner")), 103 flickr_server = int(photo("server")), 104 flickr_secret = str(photo("secret")), 105 105 ) 106 106 p.save() 107 108 if (dupe or photos("page") == photos("pages")): # If we hit a dupe or if we did the last page...109 break110 else:111 cur_page += 1107 108 if (dupe or photos("page") == photos("pages")): # If we hit a dupe or if we did the last page... 109 break 110 else: 111 cur_page += 1 112 112 }}} 113 113