1 from __future__ import unicode_literals
3 from .common import InfoExtractor
10 class WistiaIE(InfoExtractor):
11 _VALID_URL = r'(?:wistia:|https?://(?:fast\.)?wistia\.net/embed/iframe/)(?P<id>[a-z0-9]+)'
12 _API_URL = 'http://fast.wistia.com/embed/medias/%s.json'
13 _IFRAME_URL = 'http://fast.wistia.net/embed/iframe/%s'
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,
28 'url': 'wistia:sh7fpupwlt',
29 'only_matching': True,
32 def _real_extract(self, url):
33 video_id = self._match_id(url)
35 data_json = self._download_json(
36 self._API_URL % video_id, video_id,
37 # Some videos require this.
39 'Referer': url if url.startswith('http') else self._IFRAME_URL % video_id,
42 if data_json.get('error'):
44 'Error while getting the playlist', expected=True)
46 data = data_json['media']
51 for a in data['assets']:
55 astatus = a.get('status')
57 if (astatus is not None and astatus != 2) or atype in ('preview', 'storyboard'):
59 elif atype in ('still', 'still_image'):
62 'width': int_or_none(a.get('width')),
63 'height': int_or_none(a.get('height')),
69 'tbr': int_or_none(a.get('bitrate')),
70 'vbr': int_or_none(a.get('opt_vbitrate')),
71 'width': int_or_none(a.get('width')),
72 'height': int_or_none(a.get('height')),
73 'filesize': int_or_none(a.get('size')),
74 'vcodec': a.get('codec'),
75 'container': a.get('container'),
77 'preference': 1 if atype == 'original' else None,
80 self._sort_formats(formats)
85 'description': data.get('seoDescription'),
87 'thumbnails': thumbnails,
88 'duration': int_or_none(data.get('duration')),
89 'timestamp': int_or_none(data.get('createdAt')),