From 0030b75e1dcda8a1cf10dd6ce31028c5a08eb1d5 Mon Sep 17 00:00:00 2001 From: Peter Dahlberg Date: Fri, 6 Feb 2015 15:27:11 +0100 Subject: [PATCH] wp: report missing page --- plugins.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins.py b/plugins.py index cdd45b2..3109ab6 100644 --- a/plugins.py +++ b/plugins.py @@ -556,7 +556,7 @@ def command_wp(argv,lang="de",**args): response = urllib.request.urlopen(apiurl) buf = response.read(BUFSIZ) j = json.loads(buf.decode("unicode_escape")) - + page = next(iter(j['query']['pages'].values())) short = page.get("extract", None) linktitle = page.get("title", query).replace(" ","_") @@ -573,6 +573,8 @@ def command_wp(argv,lang="de",**args): short if short.strip() else "(nix)", link ) } + elif "missing" in page: + return { 'msg': 'Article "%s" not found' % page.get("title", query) } else: return { 'msg': "Something seems wrong with the json" }