diff options
author | Sergey M․ <dstftw@gmail.com> | 2015-11-14 01:23:15 +0600 |
---|---|---|
committer | Sergey M․ <dstftw@gmail.com> | 2015-11-14 01:23:15 +0600 |
commit | a2973eb59733c5f86a249c627d654b789020bc7d (patch) | |
tree | 117cfde0f1410dd0243d175818b1babf1962f493 /youtube_dl/utils.py | |
parent | 4e21b3a94f1ce7ba3757d59d1ac4baf9efaeed84 (diff) | |
parent | 9550ca506fccf9c9d795816cc0a7817ff262ef45 (diff) |
Merge branch 'brightcove_in_page_embed' of https://github.com/remitamine/youtube-dl into remitamine-brightcove_in_page_embed
Diffstat (limited to 'youtube_dl/utils.py')
-rw-r--r-- | youtube_dl/utils.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py index d39f313a4..65556d056 100644 --- a/youtube_dl/utils.py +++ b/youtube_dl/utils.py @@ -259,6 +259,15 @@ def get_element_by_attribute(attribute, value, html): return unescapeHTML(res) +def extract_attributes(attributes_str, attributes_regex=r'(?s)\s*([^\s=]+)\s*=\s*["\']([^"\']+)["\']'): + attributes = re.findall(attributes_regex, attributes_str) + attributes_dict = {} + if attributes: + for (attribute_name, attribute_value) in attributes: + attributes_dict[attribute_name] = attribute_value + return attributes_dict + + def clean_html(html): """Clean an HTML snippet into a readable string""" |