47def response(resp):
48
49 suggestions = json.loads(resp.text)
50 results = []
51
52 for entry in suggestions.get('d', []):
53
54
55 entry_id = entry['id']
56 categ = search_categories.get(entry_id[:2])
57 if categ is None:
58 logger.error('skip unknown category tag %s in %s', entry_id[:2], entry_id)
59 continue
60
61 title = entry['l']
62 if 'q' in entry:
63 title += " (%s)" % entry['q']
64
65 content = ''
66 if 'rank' in entry:
67 content += "(%s) " % entry['rank']
68 if 'y' in entry:
69 content += str(entry['y']) + " - "
70 if 's' in entry:
71 content += entry['s']
72
73
74 image_url = entry.get('i', {}).get('imageUrl')
75 if image_url:
76
77 image_url_name, image_url_prefix = image_url.rsplit('.', 1)
78
79
80
81
82
83
84 magic = 'QL75_UX280_CR0,0,280,414_'
85 if not image_url_name.endswith('_V1_'):
86 magic = '_V1_' + magic
87 image_url = image_url_name + magic + '.' + image_url_prefix
88 results.append(
89 {
90 "title": title,
91 "url": href_base.format(category=categ, entry_id=entry_id),
92 "content": content,
93 "thumbnail": image_url,
94 }
95 )
96
97 return results