mirror of
https://github.com/searx/searx
synced 2024-12-04 16:11:37 +01:00
[fix] youtube_noapi engine: fix the title
This commit is contained in:
parent
8b7ac56669
commit
0c032c8429
@ -67,12 +67,8 @@ def response(resp):
|
|||||||
if videoid is not None:
|
if videoid is not None:
|
||||||
url = base_youtube_url + videoid
|
url = base_youtube_url + videoid
|
||||||
thumbnail = 'https://i.ytimg.com/vi/' + videoid + '/hqdefault.jpg'
|
thumbnail = 'https://i.ytimg.com/vi/' + videoid + '/hqdefault.jpg'
|
||||||
title = video.get('title', {}).get('simpleText', videoid)
|
title = get_text_from_json(video.get('title', {}))
|
||||||
description_snippet = video.get('descriptionSnippet', {})
|
content = get_text_from_json(video.get('descriptionSnippet', {}))
|
||||||
if 'runs' in description_snippet:
|
|
||||||
content = reduce(lambda a, b: a + b.get('text', ''), description_snippet.get('runs'), '')
|
|
||||||
else:
|
|
||||||
content = description_snippet.get('simpleText', '')
|
|
||||||
embedded = embedded_url.format(videoid=videoid)
|
embedded = embedded_url.format(videoid=videoid)
|
||||||
|
|
||||||
# append result
|
# append result
|
||||||
@ -85,3 +81,10 @@ def response(resp):
|
|||||||
|
|
||||||
# return results
|
# return results
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
|
||||||
|
def get_text_from_json(element):
|
||||||
|
if 'runs' in element:
|
||||||
|
return reduce(lambda a, b: a + b.get('text', ''), element.get('runs'), '')
|
||||||
|
else:
|
||||||
|
return element.get('simpleText', '')
|
||||||
|
Loading…
Reference in New Issue
Block a user