[mediawiki] fix OpenSearch: can have empty description

This commit is contained in:
nemunaire 2015-09-25 07:32:46 +02:00
parent 7a1ad6430c
commit bbf5acafbb

View file

@ -70,7 +70,7 @@ def opensearch(site, term, ssl=False):
if response is not None and response.hasNode("Section"): if response is not None and response.hasNode("Section"):
for itm in response.getNode("Section").getNodes("Item"): for itm in response.getNode("Section").getNodes("Item"):
yield (itm.getNode("Text").getContent(), yield (itm.getNode("Text").getContent(),
itm.getNode("Description").getContent(), itm.getNode("Description").getContent() if itm.hasNode("Description") else "",
itm.getNode("Url").getContent()) itm.getNode("Url").getContent())
@ -163,6 +163,8 @@ def mediawiki_response(site, term, receivers):
line_treat=lambda line: irc_format(parse_wikitext(site, line, ns)), line_treat=lambda line: irc_format(parse_wikitext(site, line, ns)),
channel=receivers) channel=receivers)
except: except:
pass
# Try looking at opensearch # Try looking at opensearch
os = [x for x, _, _ in opensearch(site, terms[0])] os = [x for x, _, _ in opensearch(site, terms[0])]
# Fallback to global search # Fallback to global search