2 from __future__ import unicode_literals
6 from .common import InfoExtractor
7 from ..compat import compat_str
17 class PikselIE(InfoExtractor):
18 _VALID_URL = r'https?://player\.piksel\.com/v/(?P<id>[a-z0-9]+)'
21 'url': 'http://player.piksel.com/v/ums2867l',
22 'md5': '34e34c8d89dc2559976a6079db531e85',
26 'title': 'GX-005 with Caption',
27 'timestamp': 1481335659,
28 'upload_date': '20161210'
32 # Original source: http://www.uscourts.gov/cameras-courts/state-washington-vs-donald-j-trump-et-al
33 'url': 'https://player.piksel.com/v/v80kqp41',
34 'md5': '753ddcd8cc8e4fa2dda4b7be0e77744d',
38 'title': 'WAW- State of Washington vs. Donald J. Trump, et al',
39 'description': 'State of Washington vs. Donald J. Trump, et al, Case Number 17-CV-00141-JLR, TRO Hearing, Civil Rights Case, 02/3/2017, 1:00 PM (PST), Seattle Federal Courthouse, Seattle, WA, Judge James L. Robart presiding.',
40 'timestamp': 1486171129,
41 'upload_date': '20170204'
47 def _extract_url(webpage):
49 r'<iframe[^>]+src=["\'](?P<url>(?:https?:)?//player\.piksel\.com/v/[a-z0-9]+)',
52 return mobj.group('url')
54 def _real_extract(self, url):
55 video_id = self._match_id(url)
56 webpage = self._download_webpage(url, video_id)
57 app_token = self._search_regex([
58 r'clientAPI\s*:\s*"([^"]+)"',
59 r'data-de-api-key\s*=\s*"([^"]+)"'
60 ], webpage, 'app token')
61 response = self._download_json(
62 'http://player.piksel.com/ws/ws_program/api/%s/mode/json/apiv/5' % app_token,
66 failure = response.get('failure')
68 raise ExtractorError(response['failure']['reason'], expected=True)
69 video_data = response['WsProgramResponse']['program']['asset']
70 title = video_data['title']
74 m3u8_url = dict_get(video_data, [
81 formats.extend(self._extract_m3u8_formats(
82 m3u8_url, video_id, 'mp4', 'm3u8_native',
83 m3u8_id='hls', fatal=False))
85 asset_type = dict_get(video_data, ['assetType', 'asset_type'])
86 for asset_file in video_data.get('assetFiles', []):
87 # TODO: extract rtmp formats
88 http_url = asset_file.get('http_url')
92 vbr = int_or_none(asset_file.get('videoBitrate'), 1024)
93 abr = int_or_none(asset_file.get('audioBitrate'), 1024)
94 if asset_type == 'video':
96 elif asset_type == 'audio':
101 format_id.append(compat_str(tbr))
104 'format_id': '-'.join(format_id),
105 'url': unescapeHTML(http_url),
108 'width': int_or_none(asset_file.get('videoWidth')),
109 'height': int_or_none(asset_file.get('videoHeight')),
110 'filesize': int_or_none(asset_file.get('filesize')),
113 self._sort_formats(formats)
116 for caption in video_data.get('captions', []):
117 caption_url = caption.get('url')
119 subtitles.setdefault(caption.get('locale', 'en'), []).append({
125 'description': video_data.get('description'),
126 'thumbnail': video_data.get('thumbnailUrl'),
127 'timestamp': parse_iso8601(video_data.get('dateadd')),
129 'subtitles': subtitles,