From f567f44341883d2e026a0a001791eddfece290e1 Mon Sep 17 00:00:00 2001 From: Diederik de Haas Date: Wed, 14 Dec 2022 14:49:21 +0100 Subject: [PATCH] Try html.unescape first to escape HTML The unescape function is part of the `html` module since python 3.4 and since 3.9 it's giving an AttributeError when using `HTMLParser.unescape`, so use the `html.unescape` function by default and only fall back to the old method on error (i.e. python < 3.4). --- resources/lib/plugin.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/resources/lib/plugin.py b/resources/lib/plugin.py index f22b9f6..aec148c 100644 --- a/resources/lib/plugin.py +++ b/resources/lib/plugin.py @@ -13,6 +13,7 @@ from xbmcswift2 import Plugin +import html from html.parser import HTMLParser from urllib.request import urlopen @@ -44,7 +45,10 @@ def unescape_html(inp): >>> unescape_html('apples & oranges') apples & oranges ''' - return _parser.unescape(inp) + try: + return html.unescape(inp) + except: + return _parser.unescape(inp) def clean(inp):