4 from .common
import InfoExtractor
11 class ParliamentLiveUKIE(InfoExtractor
):
12 IE_NAME
= 'parliamentlive.tv'
13 IE_DESC
= 'UK parliament videos'
14 _VALID_URL
= r
'(?i)https?://(?:www\.)?parliamentlive\.tv/Event/Index/(?P<id>[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12})'
17 'url': 'http://parliamentlive.tv/Event/Index/c1e9d44d-fd6c-4263-b50f-97ed26cc998b',
19 'id': 'c1e9d44d-fd6c-4263-b50f-97ed26cc998b',
21 'title': 'Home Affairs Committee',
22 'timestamp': 1395153872,
23 'upload_date': '20140318',
26 'url': 'http://parliamentlive.tv/event/index/3f24936f-130f-40bf-9a5d-b3d6479da6a4',
27 'only_matching': True,
30 def _real_extract(self
, url
):
31 video_id
= self
._match
_id
(url
)
32 video_info
= self
._download
_json
(f
'https://www.parliamentlive.tv/Event/GetShareVideo/{video_id}', video_id
)
33 _DEVICE_ID
= str(uuid
.uuid4())
34 auth
= 'Bearer ' + self
._download
_json
(
35 'https://exposure.api.redbee.live/v2/customer/UKParliament/businessunit/ParliamentLive/auth/anonymous',
37 'Origin': 'https://videoplayback.parliamentlive.tv',
38 'Accept': 'application/json, text/plain, */*',
39 'Content-Type': 'application/json;charset=utf-8'
41 'deviceId': _DEVICE_ID
,
43 'deviceId': _DEVICE_ID
,
47 'name': ' Mozilla Firefox 91'
49 }).encode('utf-8'))['sessionToken']
51 video_urls
= self
._download
_json
(
52 f
'https://exposure.api.redbee.live/v2/customer/UKParliament/businessunit/ParliamentLive/entitlement/{video_id}/play',
53 video_id
, headers
={'Authorization': auth, 'Accept': 'application/json, text/plain, */*'}
)['formats']
56 for format
in video_urls
:
57 if not format
.get('mediaLocator'):
59 if format
.get('format') == 'DASH':
60 formats
.extend(self
._extract
_mpd
_formats
(
61 format
['mediaLocator'], video_id
, mpd_id
='dash', fatal
=False))
62 elif format
.get('format') == 'SMOOTHSTREAMING':
63 formats
.extend(self
._extract
_ism
_formats
(
64 format
['mediaLocator'], video_id
, ism_id
='ism', fatal
=False))
65 elif format
.get('format') == 'HLS':
66 formats
.extend(self
._extract
_m
3u8_formats
(
67 format
['mediaLocator'], video_id
, m3u8_id
='hls', fatal
=False))
69 self
._sort
_formats
(formats
)
74 'title': video_info
['event']['title'],
75 'timestamp': unified_timestamp(try_get(video_info
, lambda x
: x
['event']['publishedStartTime'])),
76 'thumbnail': video_info
.get('thumbnailUrl'),