1 from __future__ import unicode_literals
3 from .common import InfoExtractor
11 class WistiaIE(InfoExtractor):
12 _VALID_URL = r'(?:wistia:|https?://(?:fast\.)?wistia\.net/embed/iframe/)(?P<id>[a-z0-9]+)'
13 _API_URL = 'http://fast.wistia.com/embed/medias/%s.json'
14 _IFRAME_URL = 'http://fast.wistia.net/embed/iframe/%s'
17 'url': 'http://fast.wistia.net/embed/iframe/sh7fpupwlt',
18 'md5': 'cafeb56ec0c53c18c97405eecb3133df',
22 'title': 'Being Resourceful',
23 'description': 'a Clients From Hell Video Series video from worldwidewebhosting',
24 'upload_date': '20131204',
25 'timestamp': 1386185018,
29 'url': 'wistia:sh7fpupwlt',
30 'only_matching': True,
33 'url': 'wistia:807fafadvk',
34 'only_matching': True,
37 def _real_extract(self, url):
38 video_id = self._match_id(url)
40 data_json = self._download_json(
41 self._API_URL % video_id, video_id,
42 # Some videos require this.
44 'Referer': url if url.startswith('http') else self._IFRAME_URL % video_id,
47 if data_json.get('error'):
49 'Error while getting the playlist', expected=True)
51 data = data_json['media']
56 for a in data['assets']:
60 astatus = a.get('status')
62 if (astatus is not None and astatus != 2) or atype in ('preview', 'storyboard'):
64 elif atype in ('still', 'still_image'):
67 'width': int_or_none(a.get('width')),
68 'height': int_or_none(a.get('height')),
72 is_m3u8 = a.get('container') == 'm3u8' or aext == 'm3u8'
76 'tbr': int_or_none(a.get('bitrate')),
77 'vbr': int_or_none(a.get('opt_vbitrate')),
78 'width': int_or_none(a.get('width')),
79 'height': int_or_none(a.get('height')),
80 'filesize': int_or_none(a.get('size')),
81 'vcodec': a.get('codec'),
82 'container': a.get('container'),
83 'ext': 'mp4' if is_m3u8 else aext,
84 'protocol': 'm3u8' if is_m3u8 else None,
85 'preference': 1 if atype == 'original' else None,
88 self._sort_formats(formats)
93 'description': data.get('seoDescription'),
95 'thumbnails': thumbnails,
96 'duration': float_or_none(data.get('duration')),
97 'timestamp': int_or_none(data.get('createdAt')),