[adultswim] Improve segment duration extraction
authorSergey M․ <dstftw@gmail.com>
Sat, 13 Dec 2014 12:42:29 +0000 (18:42 +0600)
committerSergey M․ <dstftw@gmail.com>
Sat, 13 Dec 2014 12:42:29 +0000 (18:42 +0600)
youtube_dl/extractor/adultswim.py

index 39e4ca296f97a8fe20e65ab7160f9931fee89a67..502a9c25ad8fd6ab8fed0a46f2f52077f988aad9 100644 (file)
@@ -7,6 +7,8 @@ import json
 from .common import InfoExtractor
 from ..utils import (
     ExtractorError,
+    xpath_text,
+    float_or_none,
 )
 
 
@@ -128,7 +130,8 @@ class AdultSwimIE(InfoExtractor):
                 segment_url, segment_title,
                 'Downloading segment information', 'Unable to download segment information')
 
-            segment_duration = idoc.find('.//trt').text.strip()
+            segment_duration = float_or_none(
+                xpath_text(idoc, './/trt', 'segment duration').strip())
 
             formats = []
             file_els = idoc.findall('.//files/file')