112 results_data = response_text[response_text.find(
'ytInitialData') :]
113 results_data = results_data[results_data.find(
'{') : results_data.find(
';</script>')]
114 results_json = loads(results_data)
if results_data
else {}
116 results_json.get(
'contents', {})
117 .get(
'twoColumnSearchResultsRenderer', {})
118 .get(
'primaryContents', {})
119 .get(
'sectionListRenderer', {})
123 for section
in sections:
124 if "continuationItemRenderer" in section:
126 section[
"continuationItemRenderer"]
127 .get(
"continuationEndpoint", {})
128 .get(
"continuationCommand", {})
134 "engine_data": next_page_token,
135 "key":
"next_page_token",
138 for video_container
in section.get(
'itemSectionRenderer', {}).get(
'contents', []):
139 video = video_container.get(
'videoRenderer', {})
140 videoid = video.get(
'videoId')
141 if videoid
is not None:
142 url = base_youtube_url + videoid
143 thumbnail =
'https://i.ytimg.com/vi/' + videoid +
'/hqdefault.jpg'
157 'template':
'videos.html',
158 'iframe_src':
'https://www.youtube-nocookie.com/embed/' + videoid,
159 'thumbnail': thumbnail,