143 """Parse video response from Tubearchivist instances."""
145 json_data = resp.json()
147 if 'results' not in json_data:
150 for channel_result
in json_data[
'results'][
'channel_results']:
151 channel_url =
absolute_url(f
'/channel/{channel_result["channel_id"]}')
153 res = results.types.MainResult(
155 title=channel_result[
'channel_name'],
156 content=html_to_text(channel_result[
'channel_description']),
157 author=channel_result[
'channel_name'],
158 views=humanize_number(channel_result[
'channel_subs']),
159 thumbnail=f
'{absolute_url(channel_result["channel_thumb_url"])}?auth={ta_token}',
162 results.add(result=res)
164 for video_result
in json_data[
'results'][
'video_results']:
165 metadata = list(filter(
None, [video_result[
'channel'][
'channel_name'], *video_result.get(
'tags', [])]))[:5]
167 url = f
'{base_url.rstrip("/")}{video_result["media_url"]}'
169 url = f
'{base_url.rstrip("/")}/?videoId={video_result["youtube_id"]}'
175 'template':
'videos.html',
177 'title': video_result[
'title'],
178 'content': html_to_text(video_result[
'description']),
179 'author': video_result[
'channel'][
'channel_name'],
180 'length': video_result[
'player'][
'duration_str'],
181 'views': humanize_number(video_result[
'stats'][
'view_count']),
182 'publishedDate': parse(video_result[
'published']),
183 'thumbnail': f
'{absolute_url(video_result["vid_thumb_url"])}?auth={ta_token}',
184 'metadata':
' | '.join(metadata),
186 results.add(results.types.LegacyResult(**kwargs))