From 94c1255782414cdcda565717e31c91734ec00990 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergey=20M=E2=80=A4?= Date: Tue, 14 Apr 2015 17:50:53 +0600 Subject: [PATCH] [brightcove] Handle non well-formed XMLs (#5421) --- youtube_dl/extractor/brightcove.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/youtube_dl/extractor/brightcove.py b/youtube_dl/extractor/brightcove.py index b37857b2e..117cb00e6 100644 --- a/youtube_dl/extractor/brightcove.py +++ b/youtube_dl/extractor/brightcove.py @@ -117,7 +117,10 @@ class BrightcoveIE(InfoExtractor): object_str = re.sub(r'(]*)(xmlns=".*?")', r'\1', object_str) object_str = fix_xml_ampersands(object_str) - object_doc = xml.etree.ElementTree.fromstring(object_str.encode('utf-8')) + try: + object_doc = xml.etree.ElementTree.fromstring(object_str.encode('utf-8')) + except xml.etree.ElementTree.ParseError: + return fv_el = find_xpath_attr(object_doc, './param', 'name', 'flashVars') if fv_el is not None: @@ -185,7 +188,7 @@ class BrightcoveIE(InfoExtractor): [^>]*?>\s*\s*''', webpage) - return [cls._build_brighcove_url(m) for m in matches] + return filter(None, [cls._build_brighcove_url(m) for m in matches]) def _real_extract(self, url): url, smuggled_data = unsmuggle_url(url, {})