144 """Parse video response from Tubearchivist instances."""
146 json_data = resp.json()
148 if 'results' not in json_data:
151 for channel_result
in json_data[
'results'][
'channel_results']:
152 channel_url =
absolute_url(f
'/channel/{channel_result["channel_id"]}')
154 res = results.types.MainResult(
156 title=channel_result[
'channel_name'],
157 content=html_to_text(channel_result[
'channel_description']),
158 author=channel_result[
'channel_name'],
159 views=humanize_number(channel_result[
'channel_subs']),
160 thumbnail=f
'{absolute_url(channel_result["channel_thumb_url"])}?auth={ta_token}',
163 results.add(result=res)
165 for video_result
in json_data[
'results'][
'video_results']:
166 metadata = list(filter(
None, [video_result[
'channel'][
'channel_name'], *video_result.get(
'tags', [])]))[:5]
168 url = f
'{base_url.rstrip("/")}{video_result["media_url"]}'
170 url = f
'{base_url.rstrip("/")}/?videoId={video_result["youtube_id"]}'
176 'template':
'videos.html',
178 'title': video_result[
'title'],
179 'content': html_to_text(video_result[
'description']),
180 'author': video_result[
'channel'][
'channel_name'],
181 'length': video_result[
'player'][
'duration_str'],
182 'views': humanize_number(video_result[
'stats'][
'view_count']),
183 'publishedDate': parse(video_result[
'published']),
184 'thumbnail': f
'{absolute_url(video_result["vid_thumb_url"])}?auth={ta_token}',
185 'metadata':
' | '.join(metadata),
187 results.add(results.types.LegacyResult(**kwargs))