Fix ugly error, where wikipedia module did not return proper article. - annna - Annna the nice friendly bot. HTML git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/annna/ DIR Log DIR Files DIR Refs DIR Tags DIR README --- DIR commit af74831fa0b8078dc34540d557d277d78c367123 DIR parent 64e7fbce2f00b085fbcd25c164180a4a38272282 HTML Author: Annna Robert-Houdin <annna@bitreich.org> Date: Sat, 15 Apr 2023 22:35:54 +0200 Fix ugly error, where wikipedia module did not return proper article. Diffstat: M wikipediagame | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) --- DIR diff --git a/wikipediagame b/wikipediagame @@ -61,7 +61,14 @@ def main(args): continue if title == None: - title = str(w.random()) + summary = None + while summary == None: + title = str(w.random()) + try: + summary = w.summary(title) + except (w.exceptions.DisambiguationError, wikipedia.exceptions.PageError): + continue + if os.path.exists(hintpath): os.remove(hintpath) if os.path.exists(titlepath):