journee_mondiale: fix various issues

master
dece 2 years ago
parent 37a75f051d
commit 725aa7d681

@ -31,6 +31,7 @@ class JourneeMondialePlugin(Plugin):
""" """
REQUIRED_CONFIGS = ["commands", "dates", "no_entry_reply"] REQUIRED_CONFIGS = ["commands", "dates", "no_entry_reply"]
JMCOM_URL = "https://www.journee-mondiale.com"
def __init__(self, bot): def __init__(self, bot):
super().__init__(bot) super().__init__(bot)
@ -64,11 +65,11 @@ class JourneeMondialePlugin(Plugin):
), ),
) )
days = ", ".join(today_obs) days = ", ".join(today_obs)
return reply return days
def get_jmcom_days(self) -> str: def get_jmcom_days(self) -> str:
"""Get international days from journee-mondiale.com.""" """Get international days from journee-mondiale.com."""
response = http_get(self.config["url"]) response = http_get(JourneeMondialePlugin.JMCOM_URL)
if not response: if not response:
return "" return ""
@ -77,13 +78,16 @@ class JourneeMondialePlugin(Plugin):
try: try:
items = soup.find("div", id="journeesDuJour").find_all("article") items = soup.find("div", id="journeesDuJour").find_all("article")
for item in items: for item in items:
entries.append({ entries.append(
"url": item.find("a").href, {
"title": item.find("h2").string, "url": item.find("a").href,
}) "title": item.find("h2").string,
}
)
except (ValueError, KeyError): except (ValueError, KeyError):
return "" return ""
# TODO add plus plugin support # TODO add plus plugin support
return ", ".join(map(lambda i: i["title"], entries)) days = ", ".join(map(lambda i: i["title"], entries))
return days

Loading…
Cancel
Save