X-Git-Url: http://git.cielonegro.org/gitweb.cgi?a=blobdiff_plain;f=youtube_dl%2Futils.py;h=65556d056a7edfe12b94e82d0f55baa93360aa70;hb=a2973eb59733c5f86a249c627d654b789020bc7d;hp=d39f313a41802f38f91418e12cc89dcd798b0286;hpb=4e21b3a94f1ce7ba3757d59d1ac4baf9efaeed84;p=youtube-dl.git 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"""