本文整理汇总了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