import os
import re
-import xml.etree.ElementTree
from .common import InfoExtractor
from .youtube import YoutubeIE
ExtractorError,
HEADRequest,
+ parse_xml,
smuggle_url,
unescapeHTML,
unified_strdate,
# Is it an RSS feed?
try:
- doc = xml.etree.ElementTree.fromstring(webpage.encode('utf-8'))
+ doc = parse_xml(webpage)
if doc.tag == 'rss':
return self._extract_rss(url, video_id, doc)
except compat_xml_parse_error:
import subprocess
import sys
import traceback
+import xml.etree.ElementTree
import zlib
try:
def urlencode_postdata(*args, **kargs):
return compat_urllib_parse.urlencode(*args, **kargs).encode('ascii')
+
+
+def parse_xml(s):
+ class TreeBuilder(xml.etree.ElementTree.TreeBuilder):
+ def doctype(self, name, pubid, system):
+ pass # Ignore doctypes
+
+ parser = xml.etree.ElementTree.XMLParser(target=TreeBuilder())
+ kwargs = {'parser': parser} if sys.version_info >= (2, 7) else {}
+ return xml.etree.ElementTree.XML(s.encode('utf-8'), **kwargs)