aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/extractor
diff options
context:
space:
mode:
authorSergey M․ <dstftw@gmail.com>2016-04-10 22:55:07 +0600
committerSergey M․ <dstftw@gmail.com>2016-04-10 22:55:07 +0600
commit7ebc36900d15888321a45f04113eeda169469004 (patch)
treeb5a2fcaa2acdeba27128193cf28b4f0e731eb3b4 /youtube_dl/extractor
parentd7eb052fa2ab26839b050a7c3fa3f8874d508a02 (diff)
[jwplatform:base] Improve subtitles extraction
Diffstat (limited to 'youtube_dl/extractor')
-rw-r--r--youtube_dl/extractor/jwplatform.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/youtube_dl/extractor/jwplatform.py b/youtube_dl/extractor/jwplatform.py
index 01601c59e..8a5e562db 100644
--- a/youtube_dl/extractor/jwplatform.py
+++ b/youtube_dl/extractor/jwplatform.py
@@ -13,10 +13,6 @@ from ..utils import (
class JWPlatformBaseIE(InfoExtractor):
def _parse_jwplayer_data(self, jwplayer_data, video_id, require_title=True):
video_data = jwplayer_data['playlist'][0]
- subtitles = {}
- for track in video_data['tracks']:
- if track['kind'] == 'captions':
- subtitles[track['label']] = [{'url': self._proto_relative_url(track['file'])}]
formats = []
for source in video_data['sources']:
@@ -38,6 +34,15 @@ class JWPlatformBaseIE(InfoExtractor):
})
self._sort_formats(formats)
+ subtitles = {}
+ tracks = video_data.get('tracks')
+ if tracks and isinstance(tracks, list):
+ for track in tracks:
+ if track.get('file') and track.get('kind') == 'captions':
+ subtitles.setdefault(track.get('label') or 'en', []).append({
+ 'url': self._proto_relative_url(track['file'])
+ })
+
return {
'id': video_id,
'title': video_data['title'] if require_title else video_data.get('title'),