[jwplatform:base] Improve subtitles extraction
This commit is contained in:
parent
d7eb052fa2
commit
7ebc36900d
|
@ -13,10 +13,6 @@ from ..utils import (
|
||||||
class JWPlatformBaseIE(InfoExtractor):
|
class JWPlatformBaseIE(InfoExtractor):
|
||||||
def _parse_jwplayer_data(self, jwplayer_data, video_id, require_title=True):
|
def _parse_jwplayer_data(self, jwplayer_data, video_id, require_title=True):
|
||||||
video_data = jwplayer_data['playlist'][0]
|
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 = []
|
formats = []
|
||||||
for source in video_data['sources']:
|
for source in video_data['sources']:
|
||||||
|
@ -38,6 +34,15 @@ class JWPlatformBaseIE(InfoExtractor):
|
||||||
})
|
})
|
||||||
self._sort_formats(formats)
|
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 {
|
return {
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
'title': video_data['title'] if require_title else video_data.get('title'),
|
'title': video_data['title'] if require_title else video_data.get('title'),
|
||||||
|
|
Loading…
Reference in New Issue