135 json_data = resp.json()
137 if (
'topics' or 'posts')
not in json_data.keys():
142 for item
in json_data[
'topics']:
143 topics[item[
'id']] = item
145 for post
in json_data[
'posts']:
146 result = topics.get(post[
'topic_id'], {})
148 url = f
"{base_url}/p/{post['id']}"
149 status = gettext(
"closed")
if result.get(
'closed',
'')
else gettext(
"open")
150 comments = result.get(
'posts_count', 0)
151 publishedDate = parser.parse(result[
'created_at'])
154 metadata.append(
'@' + post.get(
'username',
''))
156 if int(comments) > 1:
157 metadata.append(f
'{gettext("comments")}: {comments}')
159 if result.get(
'has_accepted_answer'):
160 metadata.append(gettext(
"answered"))
161 elif int(comments) > 1:
162 metadata.append(status)
166 'title': html.unescape(result[
'title']),
167 'content': html.unescape(post.get(
'blurb',
'')),
168 'metadata':
' | '.join(metadata),
169 'publishedDate': publishedDate,
170 'upstream': {
'topics': result},
173 avatar = post.get(
'avatar_template',
'').replace(
'{size}',
'96')
174 if show_avatar
and avatar:
175 result[
'thumbnail'] = base_url + avatar
177 results.append(result)
179 results.append({
'number_of_results': len(json_data[
'topics'])})