summaryrefslogtreecommitdiff
path: root/searx/engines/google_videos.py
diff options
context:
space:
mode:
authorAlexandre Flament <alex@al-f.net>2019-08-01 07:44:30 +0200
committerGitHub <noreply@github.com>2019-08-01 07:44:30 +0200
commit1bed39e6cb877f75681f82fc8891f7dd4efbb9b6 (patch)
tree60321d6d247c752ab5ac2f3c242daffd6795aaf2 /searx/engines/google_videos.py
parent7f56c78876c3f1ccd73c13a1275249a42c2c2405 (diff)
parent0c032c84291954da206e8084553d91add240afd2 (diff)
Merge pull request #1658 from dalf/video-fixes
Fix dailymotion, google_videos and youtube_noapi engines
Diffstat (limited to 'searx/engines/google_videos.py')
-rw-r--r--searx/engines/google_videos.py20
1 files changed, 11 insertions, 9 deletions
diff --git a/searx/engines/google_videos.py b/searx/engines/google_videos.py
index 9a41b2dfa..fd6b2e3be 100644
--- a/searx/engines/google_videos.py
+++ b/searx/engines/google_videos.py
@@ -75,15 +75,17 @@ def response(resp):
# get thumbnails
script = str(dom.xpath('//script[contains(., "_setImagesSrc")]')[0].text)
- id = result.xpath('.//div[@class="s"]//img/@id')[0]
- thumbnails_data = re.findall('s=\'(.*?)(?:\\\\[a-z,1-9,\\\\]+\'|\')\;var ii=\[(?:|[\'vidthumb\d+\',]+)\'' + id,
- script)
- tmp = []
- if len(thumbnails_data) != 0:
- tmp = re.findall('(data:image/jpeg;base64,[a-z,A-Z,0-9,/,\+]+)', thumbnails_data[0])
- thumbnail = ''
- if len(tmp) != 0:
- thumbnail = tmp[-1]
+ ids = result.xpath('.//div[@class="s"]//img/@id')
+ if len(ids) > 0:
+ thumbnails_data = \
+ re.findall('s=\'(.*?)(?:\\\\[a-z,1-9,\\\\]+\'|\')\;var ii=\[(?:|[\'vidthumb\d+\',]+)\'' + ids[0],
+ script)
+ tmp = []
+ if len(thumbnails_data) != 0:
+ tmp = re.findall('(data:image/jpeg;base64,[a-z,A-Z,0-9,/,\+]+)', thumbnails_data[0])
+ thumbnail = ''
+ if len(tmp) != 0:
+ thumbnail = tmp[-1]
# append result
results.append({'url': url,