本文整理匯總了Python中flickrapi.FlickrAPI.groups_pools_getphotos方法的典型用法代碼示例。如果您正苦於以下問題:Python FlickrAPI.groups_pools_getphotos方法的具體用法?Python FlickrAPI.groups_pools_getphotos怎麽用?Python FlickrAPI.groups_pools_getphotos使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類flickrapi.FlickrAPI
的用法示例。
在下文中一共展示了FlickrAPI.groups_pools_getphotos方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _reload
# 需要導入模塊: from flickrapi import FlickrAPI [as 別名]
# 或者: from flickrapi.FlickrAPI import groups_pools_getphotos [as 別名]
def _reload(self):
# Here, we grab some stuff from the pool, filter it against what we already have in the
# db table, and make sure that we've got at least 20 items.
fapi = FlickrAPI(config['api_key'], config['api_secret'])
bite_size = 20
ct_checked = 0
ct_added = 0
ct_total = 200 # so long as this is > 0, we're ok.
page = 1
while ct_added < bite_size and ct_checked < ct_total:
log.debug('downloading, starting at: %d' % ct_checked)
try:
rsp = fapi.groups_pools_getphotos(apikey=config['api_key'],
group_id=config['group_id'],
page=page,
per_page=100)
except Exception, msg:
log.debug(msg.args)
return False
log.debug(rsp)
photos = rsp.find('photos')
ct_checked += int(photos.get('perpage'))
ct_total = int(photos.get('total'))
log.debug('got photos %s'%photos)
for photo in photos.getchildren():
# photo_id, date_added == the tuple of a primary key. If it's there, then we skip it.
image = photo.get('id')
log.debug('checking %s'%image)
dt = int(photo.get('dateadded'))
if PseudoPing.get(image=image, dt=dt):
log.debug('already in table')
continue
if Decision.get(image=image, fl_ok=True):
log.debug('already decided good')
continue
if not ImageHistory.get(image=image, dt=dt):
log.debug("adding image history entry, since one doesn't exist yet")
#undone -- concurrency issue here?
#undone -- check dup here?
ih = ImageHistory()
ih.image = image
ih.dt = dt
ih.save()
ImageHistory.commit()
p = PseudoPing()
p.image = image
p.dt = dt
p.owner = photo.get('owner')
p.secret = photo.get('secret')
log.debug('saving')
ct_added += 1
p.save()
if ct_added >= bite_size:
# thinking pulling just a small bite at a time would be better -- keep things fresher.
# rather than sometimes pulling in 100 at a shot.
break
page+=1