summaryrefslogtreecommitdiffstats
path: root/youtube_dl/utils.py
diff options
context:
space:
mode:
authorSergey M․ <dstftw@gmail.com>2015-06-28 23:05:49 +0600
committerSergey M․ <dstftw@gmail.com>2015-06-28 23:05:49 +0600
commite8b9ee5e08eee026016b4c06e7d47abaa82c5031 (patch)
treee6643b57b2a590fdf8dda1fa7ccdd064df989969 /youtube_dl/utils.py
parentac0474f89d3e6f8c8c1fb3223a16a18a2fd02bcb (diff)
parentd16154d16327907279eff48a4018c495726d401a (diff)
downloadyoutube-dl-e8b9ee5e08eee026016b4c06e7d47abaa82c5031.tar.gz
youtube-dl-e8b9ee5e08eee026016b4c06e7d47abaa82c5031.tar.bz2
youtube-dl-e8b9ee5e08eee026016b4c06e7d47abaa82c5031.zip
Merge branch 'gebn-moviefap'
Diffstat (limited to 'youtube_dl/utils.py')
-rw-r--r--youtube_dl/utils.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py
index 96490f112..942f76d24 100644
--- a/youtube_dl/utils.py
+++ b/youtube_dl/utils.py
@@ -62,6 +62,8 @@ std_headers = {
}
+NO_DEFAULT = object()
+
ENGLISH_MONTH_NAMES = [
'January', 'February', 'March', 'April', 'May', 'June',
'July', 'August', 'September', 'October', 'November', 'December']
@@ -171,13 +173,15 @@ def xpath_with_ns(path, ns_map):
return '/'.join(replaced)
-def xpath_text(node, xpath, name=None, fatal=False):
+def xpath_text(node, xpath, name=None, fatal=False, default=NO_DEFAULT):
if sys.version_info < (2, 7): # Crazy 2.6
xpath = xpath.encode('ascii')
n = node.find(xpath)
if n is None or n.text is None:
- if fatal:
+ if default is not NO_DEFAULT:
+ return default
+ elif fatal:
name = xpath if name is None else name
raise ExtractorError('Could not find XML element %s' % name)
else: