def _render_status_text(it, out): id = it['id'] name = it['user']['screen_name'] uid = it['user']['id'] raw_time = it['created_at'] time = utils.get_only_fanfou_date(raw_time).decode('utf8') text = it['text'] tpl = Template(template.TEXT_STATUS) status = tpl.substitute(id=id, name=name, uid=uid, time=time, text=text) out.write(status.encode('utf8'))
def _render_status_html(it, out, outDir): id = it['id'] name = it['user']['screen_name'] uid = it['user']['id'] raw_time = it['created_at'] time = utils.get_only_fanfou_date(raw_time).decode('utf8') text = it['text'] if it.get('photo'): imgfile = os.path.join('{0}-photos'.format(uid), '{0}.jpg'.format(id)) imgpath = os.path.join(outDir, imgfile) photo = imgfile if os.path.exists(imgpath) else it['photo']['url'] else: photo = '' tpl = Template(template.STATUS_TEMPLATE) status = tpl.substitute(id=id, name=name, uid=uid, raw_time=raw_time, time=time, text=text, photo_url=photo, photo_link=u'照片' if photo else '') out.write(status.encode('utf8'))