1 from __future__ import unicode_literals
6 from .common import SearchInfoExtractor
12 class GoogleSearchIE(SearchInfoExtractor):
13 IE_DESC = 'Google Video search'
15 IE_NAME = 'video.google:search'
16 _SEARCH_KEY = 'gvsearch'
18 'url': 'gvsearch15:python language',
20 'id': 'python language',
21 'title': 'python language',
26 def _get_n_results(self, query, n):
27 """Get a specified number of results for a query"""
36 for pagenum in itertools.count():
38 'http://www.google.com/search?tbm=vid&q=%s&start=%s&hl=en'
39 % (compat_urllib_parse.quote_plus(query), pagenum * 10))
41 webpage = self._download_webpage(
42 result_url, 'gvsearch:' + query,
43 note='Downloading result page ' + str(pagenum + 1))
45 for hit_idx, mobj in enumerate(re.finditer(
46 r'<h3 class="r"><a href="([^"]+)"', webpage)):
49 if not re.search(r'id="vidthumb%d"' % (hit_idx + 1), webpage):
57 if (len(entries) >= n) or not re.search(r'id="pnnext"', webpage):
58 res['entries'] = entries[:n]