2 from __future__ import unicode_literals
4 from .common import InfoExtractor
5 from ..utils import int_or_none
8 class JWPlatformIE(InfoExtractor):
9 _VALID_URL = r'(?:https?://content\.jwplatform\.com/(?:feeds|players|jw6)/|jwplatform:)(?P<id>[a-zA-Z0-9]{8})'
11 'url': 'http://content.jwplatform.com/players/nPripu9l-ALJ3XQCI.js',
12 'md5': 'fa8899fa601eb7c83a64e9d568bdf325',
16 'title': 'Big Buck Bunny Trailer',
17 'description': 'Big Buck Bunny is a short animated film by the Blender Institute. It is made using free and open source software.',
18 'upload_date': '20081127',
19 'timestamp': 1227796140,
24 def _extract_url(webpage):
26 r'<script[^>]+?src=["\'](?P<url>(?:https?:)?//content.jwplatform.com/players/[a-zA-Z0-9]{8}',
29 return mobj.group('url')
31 def _real_extract(self, url):
32 video_id = self._match_id(url)
33 json_data = self._download_json('http://content.jwplatform.com/feeds/%s.json' % video_id, video_id)
34 video_data = json_data['playlist'][0]
36 for track in video_data['tracks']:
37 if track['kind'] == 'captions':
38 subtitles[track['label']] = [{'url': self._proto_relative_url(track['file'])}]
41 for source in video_data['sources']:
42 source_url = self._proto_relative_url(source['file'])
43 source_type = source.get('type') or ''
44 if source_type == 'application/vnd.apple.mpegurl':
45 formats.extend(self._extract_m3u8_formats(source_url, video_id, 'mp4', 'm3u8_native', fatal=None))
46 elif source_type.startswith('audio'):
54 'width': int_or_none(source.get('width')),
55 'height': int_or_none(source.get('height')),
57 self._sort_formats(formats)
60 'id': video_data['mediaid'],
61 'title': video_data['title'],
62 'description': video_data.get('description'),
63 'thumbnail': self._proto_relative_url(video_data.get('image')),
64 'timestamp': int_or_none(video_data.get('pubdate')),
65 'subtitles': subtitles,