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:
parent
bc15c694c3
commit
e9fca7a771
@ -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))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user