[dailymotion] Fix subtitles extraction
authorSergey M․ <dstftw@gmail.com>
Thu, 10 Dec 2015 15:29:07 +0000 (21:29 +0600)
committerSergey M․ <dstftw@gmail.com>
Thu, 10 Dec 2015 15:29:07 +0000 (21:29 +0600)
youtube_dl/extractor/dailymotion.py

index fd6d14d23bef382934e5fbbaf9ac969d721acba5..e260a0c59b1cdb3fb1c34cfa83d14fa3b13c63f7 100644 (file)
@@ -174,11 +174,13 @@ class DailymotionIE(DailymotionBaseInfoExtractor):
             uploader_id = metadata.get('owner', {}).get('id')
 
             subtitles = {}
-            for subtitle_lang, subtitle in metadata.get('subtitles', {}).get('data', {}).items():
-                subtitles[subtitle_lang] = [{
-                    'ext': determine_ext(subtitle_url),
-                    'url': subtitle_url,
-                } for subtitle_url in subtitle.get('urls', [])]
+            subtitles_data = metadata.get('subtitles', {}).get('data', {})
+            if subtitles_data and isinstance(subtitles_data, dict):
+                for subtitle_lang, subtitle in subtitles_data.items():
+                    subtitles[subtitle_lang] = [{
+                        'ext': determine_ext(subtitle_url),
+                        'url': subtitle_url,
+                    } for subtitle_url in subtitle.get('urls', [])]
 
             return {
                 'id': video_id,