on master help sign in
Merge pull request #1689 from MarcAbonce/images_fixes

[fix] Google Images

commit05033ea8d8d3b3afb92c614a86399a499e7ad07e authorAdam Tauber <asciimoo@gmail.com> dateTue 26 Nov 2019, 13:20 (7 years ago) parent2a527b8bb4d223
1 file changed+13−3
searx/engines/google_images.py+13−3
searx/engines/google_images.py+13−3
@@ -70,11 +70,21 @@ def response(resp):
7070
7171 try:
7272 metadata = loads(result)
73− img_format = "{0} {1}x{2}".format(metadata['ity'], str(metadata['ow']), str(metadata['oh']))
74− source = "{0} ({1})".format(metadata['st'], metadata['isu'])
73+
74+ img_format = metadata.get('ity', '')
75+ img_width = metadata.get('ow', '')
76+ img_height = metadata.get('oh', '')
77+ if img_width and img_height:
78+ img_format += " {0}x{1}".format(img_width, img_height)
79+
80+ source = metadata.get('st', '')
81+ source_url = metadata.get('isu', '')
82+ if source_url:
83+ source += " ({0})".format(source_url)
84+
7585 results.append({'url': metadata['ru'],
7686 'title': metadata['pt'],
77− 'content': metadata['s'],
87+ 'content': metadata.get('s', ''),
7888 'source': source,
7989 'img_format': img_format,
8090 'thumbnail_src': metadata['tu'],