[fix] google_videos engine: some results don't a thumbnail

This commit is contained in:
Dalf 2019-07-31 08:38:45 +02:00
parent d44677e226
commit 8b7ac56669
1 changed files with 11 additions and 9 deletions

View File

@ -75,15 +75,17 @@ def response(resp):
# get thumbnails # get thumbnails
script = str(dom.xpath('//script[contains(., "_setImagesSrc")]')[0].text) script = str(dom.xpath('//script[contains(., "_setImagesSrc")]')[0].text)
id = result.xpath('.//div[@class="s"]//img/@id')[0] ids = result.xpath('.//div[@class="s"]//img/@id')
thumbnails_data = re.findall('s=\'(.*?)(?:\\\\[a-z,1-9,\\\\]+\'|\')\;var ii=\[(?:|[\'vidthumb\d+\',]+)\'' + id, if len(ids) > 0:
script) thumbnails_data = \
tmp = [] re.findall('s=\'(.*?)(?:\\\\[a-z,1-9,\\\\]+\'|\')\;var ii=\[(?:|[\'vidthumb\d+\',]+)\'' + ids[0],
if len(thumbnails_data) != 0: script)
tmp = re.findall('(data:image/jpeg;base64,[a-z,A-Z,0-9,/,\+]+)', thumbnails_data[0]) tmp = []
thumbnail = '' if len(thumbnails_data) != 0:
if len(tmp) != 0: tmp = re.findall('(data:image/jpeg;base64,[a-z,A-Z,0-9,/,\+]+)', thumbnails_data[0])
thumbnail = tmp[-1] thumbnail = ''
if len(tmp) != 0:
thumbnail = tmp[-1]
# append result # append result
results.append({'url': url, results.append({'url': url,