Browse Source

[generic] Fix on python 2.6

`ParseError` is not available, it raises `xml.parsers.expat.ExpatError`.
The webpage needs to be encoded.
totalwebcasting
Jaime Marquínez Ferrándiz 11 years ago
parent
commit
f7300c5c90
2 changed files with 8 additions and 2 deletions
  1. +3
    -2
      youtube_dl/extractor/generic.py
  2. +5
    -0
      youtube_dl/utils.py

+ 3
- 2
youtube_dl/extractor/generic.py View 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


+ 5
- 0
youtube_dl/utils.py View 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)


Loading…
Cancel
Save