aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl
diff options
context:
space:
mode:
authorPhilipp Hagemeister <phihag@phihag.de>2013-02-01 17:29:50 +0100
committerPhilipp Hagemeister <phihag@phihag.de>2013-02-01 17:29:50 +0100
commit3b024e17afcfe12f4ea55e9a200b9cbd61ec3f99 (patch)
tree04223a595f09b476ebbb971d163261bcb9983d2a /youtube_dl
parentec71c13ab891566abff9010710afb915e8f22523 (diff)
Work around buggy HTML Parser in Python < 2.7.3 (Closes #662)
Diffstat (limited to 'youtube_dl')
-rw-r--r--youtube_dl/utils.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py
index 532e8c782..e6ce028d6 100644
--- a/youtube_dl/utils.py
+++ b/youtube_dl/utils.py
@@ -280,6 +280,12 @@ class AttrParser(compat_html_parser.HTMLParser):
lines[-1] = lines[-1][:self.result[2][1]-self.result[1][1]]
lines[-1] = lines[-1][:self.result[2][1]]
return '\n'.join(lines).strip()
+# Hack for https://github.com/rg3/youtube-dl/issues/662
+if sys.version_info < (2, 7, 3):
+ AttrParser.parse_endtag = (lambda self, i:
+ i + len("</scr'+'ipt>")
+ if self.rawdata[i:].startswith("</scr'+'ipt>")
+ 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"""