[screenwavemedia] Improve formats extraction
authorSergey M․ <dstftw@gmail.com>
Sun, 28 Feb 2016 14:05:58 +0000 (20:05 +0600)
committerSergey M․ <dstftw@gmail.com>
Sun, 28 Feb 2016 14:05:58 +0000 (20:05 +0600)
youtube_dl/extractor/screenwavemedia.py

index 2cf210e0d609a219f6ac2cbd205311cc166afa29..d2af26c1ccf57377420b0594874525e9713dde22 100644 (file)
@@ -70,19 +70,19 @@ class ScreenwaveMediaIE(InfoExtractor):
 
         formats = []
         for source in sources:
-            if source['type'] == 'hls':
-                formats.extend(self._extract_m3u8_formats(source['file'], video_id, ext='mp4'))
+            file_ = source.get('file')
+            if not file_:
+                continue
+            if source.get('type') == 'hls':
+                formats.extend(self._extract_m3u8_formats(file_, video_id, ext='mp4'))
             else:
-                file_ = source.get('file')
-                if not file_:
-                    continue
                 format_label = source.get('label')
                 format_id = self._search_regex(
                     r'_(.+?)\.[^.]+$', file_, 'format id', default=None)
                 height = int_or_none(self._search_regex(
                     r'^(\d+)[pP]', format_label, 'height', default=None))
                 formats.append({
-                    'url': source['file'],
+                    'url': file_,
                     'format_id': format_id,
                     'format': format_label,
                     'ext': source.get('type'),