1 from __future__ import unicode_literals
3 from .common import InfoExtractor
11 class WistiaIE(InfoExtractor):
12 _VALID_URL = r'https?://(?:fast\.)?wistia\.net/embed/iframe/(?P<id>[a-z0-9]+)'
13 _API_URL = 'http://fast.wistia.com/embed/medias/{0:}.json'
16 'url': 'http://fast.wistia.net/embed/iframe/sh7fpupwlt',
17 'md5': 'cafeb56ec0c53c18c97405eecb3133df',
21 'title': 'Being Resourceful',
22 'description': 'a Clients From Hell Video Series video from worldwidewebhosting',
23 'upload_date': '20131204',
24 'timestamp': 1386185018,
29 def _real_extract(self, url):
30 video_id = self._match_id(url)
32 request = sanitized_Request(self._API_URL.format(video_id))
33 request.add_header('Referer', url) # Some videos require this.
34 data_json = self._download_json(request, video_id)
35 if data_json.get('error'):
36 raise ExtractorError('Error while getting the playlist',
38 data = data_json['media']
43 for a in data['assets']:
44 astatus = a.get('status')
46 if (astatus is not None and astatus != 2) or atype == 'preview':
48 elif atype in ('still', 'still_image'):
51 'resolution': '%dx%d' % (a['width'], a['height']),
57 'tbr': int_or_none(a.get('bitrate')),
58 'vbr': int_or_none(a.get('opt_vbitrate')),
59 'width': int_or_none(a.get('width')),
60 'height': int_or_none(a.get('height')),
61 'filesize': int_or_none(a.get('size')),
62 'vcodec': a.get('codec'),
63 'container': a.get('container'),
65 'preference': 1 if atype == 'original' else None,
68 self._sort_formats(formats)
73 'description': data.get('seoDescription'),
75 'thumbnails': thumbnails,
76 'duration': int_or_none(data.get('duration')),
77 'timestamp': int_or_none(data.get('createdAt')),