aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/compat.py
diff options
context:
space:
mode:
authorBrian Foley <bpfoley@gmail.com>2016-01-02 19:49:59 +0000
committerBrian Foley <bpfoley@gmail.com>2016-03-03 10:11:37 +0000
commit8bb56eeeea8154f811076c0a9093203fab224003 (patch)
tree4bfe429dc5b46b75a6ca4b6b19f411891de0686f /youtube_dl/compat.py
parent03879ff0547b6d1b96c530075cd99f99b8c74a2b (diff)
downloadyoutube-dl-8bb56eeeea8154f811076c0a9093203fab224003.tar.xz
[utils] Add extract_attributes for extracting html tag attributes
This is much more robust than just using regexps, and handles all the common scenarios, such as empty/no values, repeated attributes, entity decoding, mixed case names, and the different possible value quoting schemes.
Diffstat (limited to 'youtube_dl/compat.py')
-rw-r--r--youtube_dl/compat.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/youtube_dl/compat.py b/youtube_dl/compat.py
index b497da696..7b9afc36d 100644
--- a/youtube_dl/compat.py
+++ b/youtube_dl/compat.py
@@ -77,6 +77,11 @@ try:
except ImportError: # Python 2
from urllib import urlretrieve as compat_urlretrieve
+try:
+ from html.parser import HTMLParser as compat_HTMLParser
+except ImportError: # Python 2
+ from HTMLParser import HTMLParser as compat_HTMLParser
+
try:
from subprocess import DEVNULL
@@ -540,6 +545,7 @@ else:
from tokenize import generate_tokens as compat_tokenize_tokenize
__all__ = [
+ 'compat_HTMLParser',
'compat_HTTPError',
'compat_basestring',
'compat_chr',