|
|
|
@ -68,20 +68,9 @@ def response(resp):
|
|
|
|
|
|
|
|
|
|
search_results = raw_search_results.get('channels', {})[0].get('items', [])
|
|
|
|
|
|
|
|
|
|
if resp.search_params['category'] == 'general':
|
|
|
|
|
# parse general results
|
|
|
|
|
for result in search_results:
|
|
|
|
|
publishedDate = parser.parse(result['pubDate'])
|
|
|
|
|
|
|
|
|
|
# append result
|
|
|
|
|
results.append({'url': result['link'],
|
|
|
|
|
'title': result['title'],
|
|
|
|
|
'content': result['description'],
|
|
|
|
|
'publishedDate': publishedDate})
|
|
|
|
|
|
|
|
|
|
elif resp.search_params['category'] == 'images':
|
|
|
|
|
# parse image results
|
|
|
|
|
for result in search_results:
|
|
|
|
|
if result.get('image'):
|
|
|
|
|
# append result
|
|
|
|
|
results.append({'url': result['url'],
|
|
|
|
|
'title': result['title'],
|
|
|
|
@ -89,6 +78,16 @@ def response(resp):
|
|
|
|
|
'img_src': result['image'],
|
|
|
|
|
'template': 'images.html'})
|
|
|
|
|
|
|
|
|
|
# parse general results
|
|
|
|
|
else:
|
|
|
|
|
publishedDate = parser.parse(result['pubDate'])
|
|
|
|
|
|
|
|
|
|
# append result
|
|
|
|
|
results.append({'url': result['link'],
|
|
|
|
|
'title': result['title'],
|
|
|
|
|
'content': result['description'],
|
|
|
|
|
'publishedDate': publishedDate})
|
|
|
|
|
|
|
|
|
|
#TODO parse video, audio and file results
|
|
|
|
|
|
|
|
|
|
# return results
|
|
|
|
|