]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/wistia.py
13a079151c9c879561e3e538c49f3122f85b349b
1 from __future__
import unicode_literals
3 from .common
import InfoExtractor
4 from ..compat
import compat_urllib_request
5 from ..utils
import ExtractorError
8 class WistiaIE(InfoExtractor
):
9 _VALID_URL
= r
'https?://(?:fast\.)?wistia\.net/embed/iframe/(?P<id>[a-z0-9]+)'
10 _API_URL
= 'http://fast.wistia.com/embed/medias/{0:}.json'
13 'url': 'http://fast.wistia.net/embed/iframe/sh7fpupwlt',
14 'md5': 'cafeb56ec0c53c18c97405eecb3133df',
18 'title': 'Being Resourceful',
23 def _real_extract(self
, url
):
24 video_id
= self
._match
_id
(url
)
26 request
= compat_urllib_request
.Request(self
._API
_URL
.format(video_id
))
27 request
.add_header('Referer', url
) # Some videos require this.
28 data_json
= self
._download
_json
(request
, video_id
)
29 if data_json
.get('error'):
30 raise ExtractorError('Error while getting the playlist',
32 data
= data_json
['media']
36 for atype
, a
in data
['assets'].items():
40 'resolution': '%dx%d' % (a
['width'], a
['height']),
43 if atype
== 'preview':
49 'height': a
['height'],
50 'filesize': a
['size'],
52 'preference': 1 if atype
== 'original' else None,
55 self
._sort
_formats
(formats
)
59 'title': data
['name'],
61 'thumbnails': thumbnails
,
62 'duration': data
.get('duration'),