[mdr] Simplify xpath
authorSergey M․ <dstftw@gmail.com>
Sat, 31 Oct 2015 16:45:45 +0000 (22:45 +0600)
committerSergey M․ <dstftw@gmail.com>
Sat, 31 Oct 2015 16:45:45 +0000 (22:45 +0600)
youtube_dl/extractor/mdr.py

index e05577496478f9a892b7b332c87d44d1dea23650..a63257c5634962f269184aa384741bf911de6786 100644 (file)
@@ -74,8 +74,7 @@ class MDRIE(InfoExtractor):
         doc = self._download_xml(
             compat_urlparse.urljoin(url, data_url), video_id)
 
-        title = (xpath_text(doc, './title', 'title', default=None) or
-                 xpath_text(doc, './broadcast/broadcastName', 'title'))
+        title = xpath_text(doc, ['./title', './broadcast/broadcastName'], 'title', fatal=True)
 
         formats = []
         processed_urls = []
@@ -149,8 +148,12 @@ class MDRIE(InfoExtractor):
 
         description = xpath_text(doc, './broadcast/broadcastDescription', 'description')
         timestamp = parse_iso8601(
-            xpath_text(doc, './broadcast/broadcastDate', 'timestamp', default=None) or
-            xpath_text(doc, './broadcast/broadcastStartDate', 'timestamp', default=None))
+            xpath_text(
+                doc, [
+                    './broadcast/broadcastDate',
+                    './broadcast/broadcastStartDate',
+                    './broadcast/broadcastEndDate'],
+                'timestamp', default=None))
         duration = parse_duration(xpath_text(doc, './duration', 'duration'))
         uploader = xpath_text(doc, './rights', 'uploader')