diff --git a/plugins/linkbot.py b/plugins/linkbot.py index 4325d02..6703a76 100644 --- a/plugins/linkbot.py +++ b/plugins/linkbot.py @@ -37,11 +37,13 @@ class TitleParser(HTMLParser): if tag == "title": self.parsing_title = True elif tag == "meta": - attrs = dict(attrs_list) - if attrs.get("property", None) == "og:title": - self.parsed_title = attrs.get("content", None) - elif attrs.get("name", None) == "title": - self.parsed_title = attrs.get("content", None) + # filter None values + attrs = {name: value for name, value in attrs_list if value} + # where property="og:title" or name="title", use the "content" attribute + if attrs.get("property", None) == "og:title" and "content" in attrs: + self.parsed_title = html.unescape(attrs["content"]) + elif attrs.get("name", None) == "title" and "content" in attrs: + self.parsed_title = html.unescape(attrs["content"]) def handle_endtag(self, tag: str) -> None: match tag.lower():