def get(self, username): self.response.out.write("Due to a weird bug with flickr, this is disabled right now. "); p = flickr.people_findByUsername(username) url = p.icon_url #url = "http://photos3.flickr.com/2/buddyicons/[email protected]" self.response.out.write(url)
def search_by_user(name): user = flickr.people_findByUsername(name) photoList = flickr.people_getPublicPhotos(user.id) urls = [] for photo in photoList: urls.append(getURL(photo, 'Large', False)) for url in urls: print url
def getCollectionFromFlickr(self,repView): coll = pim.ItemCollection(view = repView) if self.username: flickrUsername = flickr.people_findByUsername(self.username) flickrPhotos = flickr.people_getPublicPhotos(flickrUsername.id,10) coll.displayName = self.username elif self.tag: flickrPhotos = flickr.photos_search(tags=self.tag,per_page=10,sort="date-posted-asc") coll.displayName = self.tag.displayName self.sidebarCollection = coll for i in flickrPhotos: photoItem = getPhotoByFlickrID(repView, i.id) if photoItem is None: photoItem = FlickrPhoto(photo=i,view=repView,parent=coll) coll.add(photoItem) repView.commit()
def get(self): if self.request.get('method') == 'listkeywords': user_object = people_findByUsername(self.request.get('username')) data = tags_getListUser(user_object.id) template_values = { 'nsid' : user_object.id, 'keywords' : data, } path = os.path.join(os.path.dirname(__file__),TEMPLATE_DIR,TAG_LIST) elif self.request.get('method') == 'listphotos': data = photos_search(self.request.get('username'),False,self.request.get('tags').encode('utf-8')) template_values = { 'photos' : data, } path = os.path.join(os.path.dirname(__file__),TEMPLATE_DIR,THUMB_LIST) self.response.out.write(template.render(path, template_values).decode('utf-8'))
def fillCollectionFromFlickr(self, view, n=16, apiKey=None): """ Fills the collection with photos from the flickr website. """ if apiKey: flickr.setLicense(apiKey) if self.userName: flickrUserName = flickr.people_findByUsername( self.userName.encode('utf8')) flickrPhotos = flickr.people_getPublicPhotos(flickrUserName.id, n) elif self.tag: flickrPhotos = flickr.photos_search(tags=self.tag, per_page=n, sort="date-posted-desc") else: assert (False, "we should have either a userName or tag") # flickrPhotosCollection is a collection of all FlickrPhotos. It has # an index named flickerIDIndex which indexes all the photos by # their flickrID which makes it easy to quickly lookup any photo by # index. flickrPhotosCollection = schema.ns('flickr', view).flickrPhotosCollection for flickrPhoto in flickrPhotos: """ If we've already downloaded a photo with this id use it instead. """ photoUUID = flickrPhotosCollection.findInIndex( 'flickrIDIndex', # name of Index 'exact', # require an exact match # compare function lambda uuid: cmp(flickrPhoto.id, view.findValue(uuid, 'flickrID'))) if photoUUID is None: photoItem = FlickrPhoto(photo=flickrPhoto, itsView=view) else: photoItem = view[photoUUID] self.add(photoItem) view.commit()
def fillCollectionFromFlickr(self, view, n=16, apiKey=None): """ Fills the collection with photos from the flickr website. """ if apiKey: flickr.setLicense(apiKey) if self.userName: flickrUserName = flickr.people_findByUsername(self.userName.encode('utf8')) flickrPhotos = flickr.people_getPublicPhotos(flickrUserName.id, n) elif self.tag: flickrPhotos = flickr.photos_search(tags=self.tag, per_page=n, sort="date-posted-desc") else: assert(False, "we should have either a userName or tag") # flickrPhotosCollection is a collection of all FlickrPhotos. It has # an index named flickerIDIndex which indexes all the photos by # their flickrID which makes it easy to quickly lookup any photo by # index. flickrPhotosCollection = schema.ns('flickr', view).flickrPhotosCollection for flickrPhoto in flickrPhotos: """ If we've already downloaded a photo with this id use it instead. """ photoUUID = flickrPhotosCollection.findInIndex( 'flickrIDIndex', # name of Index 'exact', # require an exact match # compare function lambda uuid: cmp(flickrPhoto.id, view.findValue(uuid, 'flickrID'))) if photoUUID is None: photoItem = FlickrPhoto(photo=flickrPhoto, itsView=view) else: photoItem = view[photoUUID] self.add(photoItem) view.commit()
#!/usr/bin/python # -*- coding: utf-8 -*- import flickr method = 'flickr.photos.getRecent' #url=flickr._getURL(method) user=flickr.people_findByUsername('enguillem') #print "prova", method,"url",url,"user",dir(user) fotos=flickr.photos_search(user.id,tags='dinar') print fotos for foto in fotos: print "FOTO:",foto.getURL()
def _ProcessUsername(self): util.debugLog("processing username " + self._searchParams["username"]) user = flickr.people_findByUsername(self._searchParams["username"]) self._ProcessUserPages(user)
__date__ = "2010-12-17" __copyright__ = "Copyright 2010 Matt Gauger" import sys import os import urllib import flickr # http://code.google.com/p/flickrpy/ # Generate keys and FILL THESE OUT # http://www.flickr.com/services/apps/create/noncommercial/ flickr.API_KEY = '' flickr.API_SECRET = '' # find this on http://www.flickr.com/account # it's whatever it says next to "Your screen name" me = flickr.people_findByUsername("") page = 1 total_photos = found_photos = 0 while 1: try: photos = flickr.people_getPublicPhotos(me.id, 100, page) for photo in photos: total_photos += 1 # skip if we already have this photo have_photo = os.path.exists("%s_%s_%s_o.jpg" % (photo.server, photo.id, photo.secret)) if not have_photo: data = urllib.urlretrieve("http://static.flickr.com/%s/%s_%s_o.jpg" % (photo.server, photo.id, photo.secret), "%s_%s_%s_o.jpg" % (photo.server, photo.id, photo.secret)) print "save %s" % photo.title found_photos += 1