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
))
48 'title': media
['displayInfo']['title'],
50 'age_limit': int_or_none(media
['displayInfo']['ageGroup']),
53 def _call_api(self
, endpoint
, media_id
, method
, params
):
54 rand_uuid
= str(uuid
.uuid4())
55 res
= self
._download
_json
(
56 f
'https://b2c-mobile.redefine.pl/rpc/{endpoint}/', media_id
,
57 note
=f
'Downloading {method} JSON metadata',
65 'deviceType': 'mobile',
66 'application': 'native',
77 'clientId': rand_uuid
,
81 headers
={'Content-type': 'application/json'})
82 if not res
.get('result'):
83 if res
['error']['code'] == 13404:
84 raise ExtractorError('This video is either unavailable in your region or is DRM protected', expected
=True)
85 raise ExtractorError(f
'Solorz said: {res["error"]["message"]} - {res["error"]["data"]["userMessage"]}')