]> git.bitcoin.ninja Git - youtube-dl/commitdiff
[generic] Fix on python 2.6
authorJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com>
Fri, 21 Feb 2014 15:59:10 +0000 (16:59 +0100)
committerJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com>
Fri, 21 Feb 2014 15:59:10 +0000 (16:59 +0100)
`ParseError` is not available, it raises `xml.parsers.expat.ExpatError`.
The webpage needs to be encoded.

youtube_dl/extractor/generic.py
youtube_dl/utils.py

index 30160d59d4218601a7bff538f6fd96cc130bd7a4..9a2e54d149011f66b08d09860078f23ecf8607a9 100644 (file)
@@ -13,6 +13,7 @@ from ..utils import (
     compat_urllib_parse,
     compat_urllib_request,
     compat_urlparse,
+    compat_xml_parse_error,
 
     ExtractorError,
     HEADRequest,
@@ -241,10 +242,10 @@ class GenericIE(InfoExtractor):
 
         # Is it an RSS feed?
         try:
-            doc = xml.etree.ElementTree.fromstring(webpage)
+            doc = xml.etree.ElementTree.fromstring(webpage.encode('utf-8'))
             if doc.tag == 'rss':
                 return self._extract_rss(url, video_id, doc)
-        except xml.etree.ElementTree.ParseError:
+        except compat_xml_parse_error:
             pass
 
         # it's tempting to parse this further, but you would
index 057cd20d1d70977dd9e56e3d857907a648b228c8..471516b8f6764d26c01818246b95e2e8b20c93fb 100644 (file)
@@ -174,6 +174,11 @@ try:
 except NameError:
     compat_chr = chr
 
+try:
+    from xml.etree.ElementTree import ParseError as compat_xml_parse_error
+except ImportError:  # Python 2.6
+    from xml.parsers.expat import ExpatError as compat_xml_parse_error
+
 def compat_ord(c):
     if type(c) is int: return c
     else: return ord(c)