diff options
author | Alexandre Flament <alex@al-f.net> | 2020-12-11 13:14:03 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-11 13:14:03 +0100 |
commit | 6bc6d5e9fd2f85948a2690cf5710405d08489be8 (patch) | |
tree | cc3fa6f7b8b67de4d12cf76d226e402b36aaf1d0 | |
parent | 820b468bfe96f693d60ce06f1e78af51f00deefc (diff) | |
parent | fa73f10f11c6421eeede4c77ccd394d98fb389d4 (diff) | |
download | searxng-6bc6d5e9fd2f85948a2690cf5710405d08489be8.tar.gz searxng-6bc6d5e9fd2f85948a2690cf5710405d08489be8.zip |
Merge pull request #2371 from dalf/mod-genius
[mod) genious: return valid results even if contents are empty
-rw-r--r-- | searx/engines/genius.py | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/searx/engines/genius.py b/searx/engines/genius.py index feb7d79d1..2bfbfddf5 100644 --- a/searx/engines/genius.py +++ b/searx/engines/genius.py @@ -36,7 +36,7 @@ def parse_lyric(hit): try: content = hit['highlights'][0]['value'] except: - content = None + content = '' timestamp = hit['result']['lyrics_updated_at'] result = {'url': hit['result']['url'], 'title': hit['result']['full_title'], @@ -51,7 +51,7 @@ def parse_lyric(hit): def parse_artist(hit): result = {'url': hit['result']['url'], 'title': hit['result']['name'], - 'content': None, + 'content': '', 'thumbnail': hit['result']['image_url'], 'template': 'videos.html'} return result @@ -61,6 +61,7 @@ def parse_album(hit): result = {'url': hit['result']['url'], 'title': hit['result']['full_title'], 'thumbnail': hit['result']['cover_art_url'], + 'content': '', # 'thumbnail': hit['result']['cover_art_thumbnail_url'], 'template': 'videos.html'} try: @@ -81,9 +82,7 @@ def response(resp): json = loads(resp.text) hits = [hit for section in json['response']['sections'] for hit in section['hits']] for hit in hits: - try: - func = parse[hit['type']] - except KeyError: - continue - results.append(func(hit)) + func = parse.get(hit['type']) + if func: + results.append(func(hit)) return results |