forked from Icycoide/searxng
[fix] fixes google play engines and adds thumbnails to their results (#1612)
fix google play apps, google play apps, google play music engines xpath engine: thumbnail_xpath can define an optional thumbnail
This commit is contained in:
parent
d0dd296424
commit
87baa74a86
2 changed files with 37 additions and 17 deletions
|
@ -7,6 +7,7 @@ search_url = None
|
|||
url_xpath = None
|
||||
content_xpath = None
|
||||
title_xpath = None
|
||||
thumbnail_xpath = False
|
||||
paging = False
|
||||
suggestion_xpath = ''
|
||||
results_xpath = ''
|
||||
|
@ -40,7 +41,9 @@ def extract_text(xpath_results):
|
|||
return ''.join(xpath_results)
|
||||
else:
|
||||
# it's a element
|
||||
text = html.tostring(xpath_results, encoding='unicode', method='text', with_tail=False)
|
||||
text = html.tostring(
|
||||
xpath_results, encoding='unicode', method='text', with_tail=False
|
||||
)
|
||||
text = text.strip().replace('\n', ' ')
|
||||
return ' '.join(text.split())
|
||||
|
||||
|
@ -105,7 +108,18 @@ def response(resp):
|
|||
url = extract_url(result.xpath(url_xpath), search_url)
|
||||
title = extract_text(result.xpath(title_xpath))
|
||||
content = extract_text(result.xpath(content_xpath))
|
||||
results.append({'url': url, 'title': title, 'content': content})
|
||||
tmp_result = {'url': url, 'title': title, 'content': content}
|
||||
|
||||
# add thumbnail if available
|
||||
thumbnail = None
|
||||
if thumbnail_xpath:
|
||||
thumbnail = extract_url(
|
||||
result.xpath(thumbnail_xpath), search_url
|
||||
)
|
||||
if thumbnail:
|
||||
tmp_result['img_src'] = thumbnail
|
||||
|
||||
results.append(tmp_result)
|
||||
else:
|
||||
for url, title, content in zip(
|
||||
(extract_url(x, search_url) for
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue