X-Git-Url: http://git.cielonegro.org/gitweb.cgi?a=blobdiff_plain;f=youtube_dl%2Futils.py;h=16651bf110bae2fd8d71799d0c60ee6d90bf4fb9;hb=12ea2f30cfcc381eb46cc99a0a4c3d468fe732d1;hp=233286de840983142f4a89a5ea2cd3db6507fcae;hpb=ecc0c5ee01f0e5bdd6af0c32cb5b4adcb2a2f78c;p=youtube-dl.git diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py index 233286de8..16651bf11 100644 --- a/youtube_dl/utils.py +++ b/youtube_dl/utils.py @@ -152,7 +152,9 @@ def xpath_text(node, xpath, name=None, fatal=False): return n.text -compat_html_parser.locatestarttagend = re.compile(r"""<[a-zA-Z][-.a-zA-Z0-9:_]*(?:\s+(?:(?<=['"\s])[^\s/>][^\s/=>]*(?:\s*=+\s*(?:'[^']*'|"[^"]*"|(?!['"])[^>\s]*))?\s*)*)?\s*""", re.VERBOSE) # backport bugfix +if sys.version_info < (2, 7): + compat_html_parser.locatestarttagend = re.compile(r"""<[a-zA-Z][-.a-zA-Z0-9:_]*(?:\s+(?:(?<=['"\s])[^\s/>][^\s/=>]*(?:\s*=+\s*(?:'[^']*'|"[^"]*"|(?!['"])[^>\s]*))?\s*)*)?\s*""", re.VERBOSE) # backport bugfix + class BaseHTMLParser(compat_html_parser.HTMLParser): def __init(self): compat_html_parser.HTMLParser.__init__(self) @@ -229,10 +231,12 @@ if sys.version_info < (2, 7, 3): if self.rawdata[i:].startswith("") else compat_html_parser.HTMLParser.parse_endtag(self, i)) + def get_element_by_id(id, html): """Return the content of the tag with the specified ID in the passed HTML document""" return get_element_by_attribute("id", id, html) + def get_element_by_attribute(attribute, value, html): """Return the content of the tag with the specified attribute in the passed HTML document""" parser = AttrParser(attribute, value) @@ -263,16 +267,6 @@ class MetaParser(BaseHTMLParser): def get_result(self): return self.result -def get_meta_content(name, html): - """ - Return the content attribute from the meta tag with the given name attribute. - """ - parser = MetaParser(name) - try: - parser.loads(html) - except compat_html_parser.HTMLParseError: - pass - return parser.get_result() def clean_html(html):