Handle blank descriptions from google in the google search plugin.

This commit is contained in:
Chris Skalenda 2010-07-08 19:18:25 -06:00
parent ee69022baa
commit b9f74dba71
1 changed files with 8 additions and 2 deletions

View File

@ -37,8 +37,14 @@ def google(inp):
result = parsed['responseData']['results'][0]
title, content = map(lambda x: http.html.fromstring(x).text_content(),
(result['titleNoFormatting'], result['content']))
title = result['titleNoFormatting']
content = result['content']
if len(content) == 0:
content = "No description available"
else:
content = http.html.fromstring(content).text_content()
out = '%s -- \x02%s\x02: "%s"' % (result['unescapedUrl'], title, content)
out = ' '.join(out.split())