diff --git a/funcs/gwendolynFuncs.py b/funcs/gwendolynFuncs.py index cdde27f..6e70313 100644 --- a/funcs/gwendolynFuncs.py +++ b/funcs/gwendolynFuncs.py @@ -126,15 +126,21 @@ def findWikiPage(search : str): wikia.set_lang("da") searchResults = wikia.search("senkulpa",search) if len(searchResults) > 0: - logThis("Found it") - page = wikia.page("senkulpa",searchResults[0]) - content = page.content.replace(u'\xa0', u' ').split("\n")[0] + try: + searchResult = searchResults[0].replace(",","%2C") + logThis("Found it") + page = wikia.page("senkulpa",searchResult) + content = page.content.replace(u'\xa0', u' ').split("\n")[0] - images = page.images - if len(images) > 0: - return page.title, content, images[0]+"/revision/latest?path-prefix=da" - else: - return page.title, content, "" + images = page.images + if len(images) > 0: + image = images[len(images)-1]+"/revision/latest?path-prefix=da" + return page.title, content, image + else: + return page.title, content, "" + except: + logThis("Fucked up") + return "", "Sorry. Fucked that one up", "" else: logThis("Couldn't find the page") return "", "Couldn't find page", "" \ No newline at end of file