aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/utils.py
diff options
context:
space:
mode:
authorPhilipp Hagemeister <phihag@phihag.de>2014-09-13 09:09:55 +0200
committerPhilipp Hagemeister <phihag@phihag.de>2014-09-13 09:09:57 +0200
commitbf0ff93277ba36fbda70223ca7e78b5132e54ddf (patch)
tree48944267037d6d8f6ae18533ed9b203444c3e9ee /youtube_dl/utils.py
parentdc752ff442f74926b3301cf26f6e418e5cf8ec7f (diff)
[ard] Make more robust against missing thumbnails
I cannot reproduce this error, it's from travis.
Diffstat (limited to 'youtube_dl/utils.py')
-rw-r--r--youtube_dl/utils.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py
index 8828161e5..7536b3b36 100644
--- a/youtube_dl/utils.py
+++ b/youtube_dl/utils.py
@@ -304,6 +304,17 @@ def xpath_with_ns(path, ns_map):
return '/'.join(replaced)
+def xpath_text(node, xpath, name=None, fatal=False):
+ n = node.find(xpath)
+ if n is None:
+ if fatal:
+ name = xpath if name is None else name
+ raise ExtractorError('Could not find XML element %s' % name)
+ else:
+ return None
+ return n.text
+
+
compat_html_parser.locatestarttagend = re.compile(r"""<[a-zA-Z][-.a-zA-Z0-9:_]*(?:\s+(?:(?<=['"\s])[^\s/>][^\s/=>]*(?:\s*=+\s*(?:'[^']*'|"[^"]*"|(?!['"])[^>\s]*))?\s*)*)?\s*""", re.VERBOSE) # backport bugfix
class BaseHTMLParser(compat_html_parser.HTMLParser):
def __init(self):