def meta(cls, cont): meta = Meta() meta.original_url = zc.ARTICLE_URL.format(cont['id']) meta.voteup = cont['voteup_count'] meta.title = cont['title'] meta.background = cont['image_url'] meta.created_date = timer.timestamp_to_date(cont['created']) meta.author = cont['author']['name'] meta.author_page = zc.AUTHOR_PAGE_URL.format( cont['author']['url_token']) meta.author_avatar_url = cont['author']['avatar_url'] return meta
def parse_data(cls, data): meta = Meta() meta.title = data['question']['title'] meta.author = data['author']['name'] meta.voteup = data['voteup_count'] meta.original_url = API.format_url( 'answer_link', question_id=data['question']['id'], answer_id=data['id']) meta.created_date = timer.timestamp_to_date(data['created_time']) meta.author_homepage = API.format_url( 'author_homepage', user_id=data['author']['url_token']) meta.author_avatar_url = data['author']['avatar_url_template'].format(size='l') return meta, data.get('content')
def meta(cls, cont): meta = Meta() meta.author = cont['author']['name'] meta.voteup = cont['voteup_count'] meta.title = cont['question']['title'] question_id = cont['question']['id'] answer_id = cont['id'] meta.original_url = zc.ANSWER_URL.format(question_id, answer_id) meta.author_page = zc.AUTHOR_PAGE_URL.format( cont['author']['url_token']) meta.author_avatar_url = \ cont['author']['avatar_url_template'].replace( zc.AVATAR_SIZE_R, zc.AVATAR_SIZE_A) meta.created_date = timer.timestamp_to_date(cont['created_time']) return meta