def add_new_gif(visible_gifs, gif):
"""Add new gif to visible gifs, this might push the oldest away
from visible!
"""
new_gif = {
'id': gif['id'],
'position': {'bottom': 40, 'left': 50},
'height': gif['height'],
'added': int(time.time())
}
if len(visible_gifs) >= settings['maxVisible']:
oldest = visible_gifs.pop(0)
logger.info('Popped oldest %s' % oldest['id'])
# Take position from the oldest
new_gif['position'] = oldest['position']
new_gif['height'] = oldest['height']
visible_gifs.append(new_gif)
评论列表
文章目录