]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/jwplatform.py
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
7 from ..utils
import int_or_none
10 class JWPlatformIE(InfoExtractor
):
11 _VALID_URL
= r
'(?:https?://content\.jwplatform\.com/(?:feeds|players|jw6)/|jwplatform:)(?P<id>[a-zA-Z0-9]{8})'
13 'url': 'http://content.jwplatform.com/players/nPripu9l-ALJ3XQCI.js',
14 'md5': 'fa8899fa601eb7c83a64e9d568bdf325',
18 'title': 'Big Buck Bunny Trailer',
19 'description': 'Big Buck Bunny is a short animated film by the Blender Institute. It is made using free and open source software.',
20 'upload_date': '20081127',
21 'timestamp': 1227796140,
26 def _extract_url(webpage
):
28 r
'<script[^>]+?src=["\'](?P
<url
>(?
:https?
:)?
//content
.jwplatform
.com
/players
/[a
-zA
-Z0
-9]{8}
)',
31 return mobj.group('url
')
33 def _real_extract(self, url):
34 video_id = self._match_id(url)
35 json_data = self._download_json('http
://content
.jwplatform
.com
/feeds
/%s.json
' % video_id, video_id)
36 video_data = json_data['playlist
'][0]
38 for track in video_data['tracks
']:
39 if track['kind
'] == 'captions
':
40 subtitles[track['label
']] = [{'url
': self._proto_relative_url(track['file'])}]
43 for source in video_data['sources
']:
44 source_url = self._proto_relative_url(source['file'])
45 source_type = source.get('type') or ''
46 if source_type == 'application
/vnd
.apple
.mpegurl
':
47 formats.extend(self._extract_m3u8_formats(
48 source_url, video_id, 'mp4
', 'm3u8_native
', fatal=False))
49 elif source_type.startswith('audio
'):
57 'width
': int_or_none(source.get('width
')),
58 'height
': int_or_none(source.get('height
')),
60 self._sort_formats(formats)
64 'title
': video_data['title
'],
65 'description
': video_data.get('description
'),
66 'thumbnail
': self._proto_relative_url(video_data.get('image
')),
67 'timestamp
': int_or_none(video_data.get('pubdate
')),
68 'subtitles
': subtitles,