diff options
author | Philipp Hagemeister <phihag@phihag.de> | 2014-03-10 17:31:32 +0100 |
---|---|---|
committer | Philipp Hagemeister <phihag@phihag.de> | 2014-03-10 17:31:32 +0100 |
commit | bcf89ce62cb4f6ab8802ab6aef01c3afaefc0075 (patch) | |
tree | 3693c4b11bae2b37affe5e7af2efa30e910d794f /youtube_dl/utils.py | |
parent | e3899d0e00167c7d9675ab3a77bc77b679586ee8 (diff) |
[generic] Suppress warning about doctypes in RSS parser
Diffstat (limited to 'youtube_dl/utils.py')
-rw-r--r-- | youtube_dl/utils.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py index d4abd4031..3943cc9c5 100644 --- a/youtube_dl/utils.py +++ b/youtube_dl/utils.py @@ -22,6 +22,7 @@ import struct import subprocess import sys import traceback +import xml.etree.ElementTree import zlib try: @@ -1267,3 +1268,13 @@ def read_batch_urls(batch_fd): 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) |