4 from .common
import InfoExtractor
13 class PolsatGoIE(InfoExtractor
):
14 _VALID_URL
= r
'https?://(?:www\.)?polsat(?:box)?go\.pl/.+/(?P<id>[0-9a-fA-F]+)(?:[/#?]|$)'
16 'url': 'https://polsatgo.pl/wideo/seriale/swiat-wedlug-kiepskich/5024045/sezon-1/5028300/swiat-wedlug-kiepskich-odcinek-88/4121',
20 'title': 'Świat według Kiepskich - Odcinek 88',
25 def _extract_formats(self
, sources
, video_id
):
26 for source
in sources
or []:
27 if not source
.get('id'):
29 url
= url_or_none(self
._call
_api
(
30 'drm', video_id
, 'getPseudoLicense',
31 {'mediaId': video_id, 'sourceId': source['id']}
).get('url'))
36 'height': int_or_none(try_get(source
, lambda x
: x
['quality'][:-1]))
39 def _real_extract(self
, url
):
40 video_id
= self
._match
_id
(url
)
41 media
= self
._call
_api
('navigation', video_id
, 'prePlayData', {'mediaId': video_id}
)['mediaItem']
43 formats
= list(self
._extract
_formats
(
44 try_get(media
, lambda x
: x
['playback']['mediaSources']), video_id
))
45 self
._sort
_formats
(formats
)
49 'title': media
['displayInfo']['title'],
51 'age_limit': int_or_none(media
['displayInfo']['ageGroup'])
54 def _call_api(self
, endpoint
, media_id
, method
, params
):
55 rand_uuid
= str(uuid4())
56 res
= self
._download
_json
(
57 f
'https://b2c-mobile.redefine.pl/rpc/{endpoint}/', media_id
,
58 note
=f
'Downloading {method} JSON metadata',
66 'deviceType': 'mobile',
67 'application': 'native',
78 'clientId': rand_uuid
,
82 headers
={'Content-type': 'application/json'}
)
83 if not res
.get('result'):
84 if res
['error']['code'] == 13404:
85 raise ExtractorError('This video is either unavailable in your region or is DRM protected', expected
=True)
86 raise ExtractorError(f
'Solorz said: {res["error"]["message"]} - {res["error"]["data"]["userMessage"]}')