1
0
mirror of https://github.com/spaam/svtplay-dl.git synced 2024-11-23 19:55:38 +01:00

utils.text: py3 version of html.unescape

This commit is contained in:
Johan Andersson 2019-09-07 12:24:59 +02:00
parent bc15c694c3
commit e9fca7a771

View File

@ -1,6 +1,6 @@
from __future__ import absolute_import
import html.parser as HTMLParser
import html
import re
import unicodedata
@ -22,10 +22,9 @@ def decode_html_entities(s):
>>> print(decode_html_entities("<3 &"))
<3 &
"""
parser = HTMLParser.HTMLParser()
def unesc(m):
return parser.unescape(m.group())
return html.unescape(m.group())
return re.sub(r"(&[^;]+;)", unesc, ensure_unicode(s))