3 from .common
import InfoExtractor
15 class PikselIE(InfoExtractor
):
16 _VALID_URL
= r
'''(?x)https?://
24 (?:api|player)\.multicastmedia|
25 (?:api-ovp|player)\.piksel
31 vidego\.baltimorecity\.gov
32 )/v/(?:refid/(?P<refid>[^/]+)/prefid/)?(?P<id>[\w-]+)'''
33 _EMBED_REGEX
= [r
'<iframe[^>]+src=["\'](?P
<url
>(?
:https?
:)?
//player\
.piksel\
.com
/v
/[a
-z0
-9]+)']
36 'url
': 'http
://player
.piksel
.com
/v
/ums2867l
',
37 'md5
': '34e34c8d89dc2559976a6079db531e85
',
41 'title
': 'GX
-005 with Caption
',
42 'timestamp
': 1481335659,
43 'upload_date
': '20161210'
47 # Original source: http://www.uscourts.gov/cameras-courts/state-washington-vs-donald-j-trump-et-al
48 'url
': 'https
://player
.piksel
.com
/v
/v80kqp41
',
49 'md5
': '753ddcd8cc8e4fa2dda4b7be0e77744d
',
53 'title
': 'WAW
- State of Washington vs
. Donald J
. Trump
, et al
',
54 '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
.',
55 'timestamp
': 1486171129,
56 'upload_date
': '20170204'
60 # https://www3.nhk.or.jp/nhkworld/en/ondemand/video/2019240/
61 'url
': 'http
://player
.piksel
.com
/v
/refid
/nhkworld
/prefid
/nw_vod_v_en_2019_240_20190823233000_02_1566873477
',
62 'only_matching
': True,
66 def _call_api(self, app_token, resource, display_id, query, fatal=True):
67 response = (self._download_json(
68 'http
://player
.piksel
.com
/ws
/ws_
%s/api
/%s/mode
/json
/apiv
/5' % (resource, app_token),
69 display_id, query=query, fatal=fatal) or {}).get('response
')
70 failure = try_get(response, lambda x: x['failure
']['reason
'])
73 raise ExtractorError(failure, expected=True)
74 self.report_warning(failure)
77 def _real_extract(self, url):
78 ref_id, display_id = self._match_valid_url(url).groups()
79 webpage = self._download_webpage(url, display_id)
80 app_token = self._search_regex([
81 r'clientAPI\s
*:\s
*"([^"]+)"',
82 r'data-de-api-key\s*=\s*"([^
"]+)"'
83 ], webpage, 'app token
')
84 query = {'refid': ref_id, 'prefid': display_id} if ref_id else {'v': display_id}
85 program = self._call_api(
86 app_token, 'program
', display_id, query)['WsProgramResponse
']['program
']
87 video_id = program['uuid
']
88 video_data = program['asset
']
89 title = video_data['title
']
90 asset_type = dict_get(video_data, ['assetType
', 'asset_type
'])
94 def process_asset_file(asset_file):
97 # TODO: extract rtmp formats
98 http_url = asset_file.get('http_url
')
102 vbr = int_or_none(asset_file.get('videoBitrate
'), 1024)
103 abr = int_or_none(asset_file.get('audioBitrate
'), 1024)
104 if asset_type == 'video
':
106 elif asset_type == 'audio
':
110 'format_id
': join_nonempty('http
', tbr),
111 'url
': unescapeHTML(http_url),
114 'width
': int_or_none(asset_file.get('videoWidth
')),
115 'height
': int_or_none(asset_file.get('videoHeight
')),
116 'filesize
': int_or_none(asset_file.get('filesize
')),
120 def process_asset_files(asset_files):
121 for asset_file in (asset_files or []):
122 process_asset_file(asset_file)
124 process_asset_files(video_data.get('assetFiles
'))
125 process_asset_file(video_data.get('referenceFile
'))
127 asset_id = video_data.get('assetid
') or program.get('assetid
')
129 process_asset_files(try_get(self._call_api(
130 app_token, 'asset_file
', display_id, {
132 }, False), lambda x: x['WsAssetFileResponse
']['AssetFiles
']))
134 m3u8_url = dict_get(video_data, [
141 formats.extend(self._extract_m3u8_formats(
142 m3u8_url, video_id, 'mp4
', 'm3u8_native
',
143 m3u8_id='hls
', fatal=False))
145 smil_url = dict_get(video_data, ['httpSmil
', 'hdSmil
', 'rtmpSmil
'])
147 transform_source = None
148 if ref_id == 'nhkworld
':
149 # TODO: figure out if this is something to be fixed in urljoin,
150 # _parse_smil_formats or keep it here
151 transform_source = lambda x: x.replace('src
="/', 'src="').replace('/media
"', '/media/"')
152 formats.extend(self._extract_smil_formats(
153 re.sub(r'/od
/[^
/]+/', '/od
/http
/', smil_url), video_id,
154 transform_source=transform_source, fatal=False))
157 for caption in video_data.get('captions
', []):
158 caption_url = caption.get('url
')
160 subtitles.setdefault(caption.get('locale
', 'en
'), []).append({
166 'description
': video_data.get('description
'),
167 'thumbnail
': video_data.get('thumbnailUrl
'),
168 'timestamp
': parse_iso8601(video_data.get('dateadd
')),
170 'subtitles
': subtitles,
171 '_format_sort_fields
': ('tbr
', ), # Incomplete resolution information