2 from __future__
import unicode_literals
7 from .common
import InfoExtractor
14 class ParliamentLiveUKIE(InfoExtractor
):
15 IE_NAME
= 'parliamentlive.tv'
16 IE_DESC
= 'UK parliament videos'
17 _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})'
20 'url': 'http://parliamentlive.tv/Event/Index/c1e9d44d-fd6c-4263-b50f-97ed26cc998b',
22 'id': 'c1e9d44d-fd6c-4263-b50f-97ed26cc998b',
24 'title': 'Home Affairs Committee',
25 'timestamp': 1395153872,
26 'upload_date': '20140318',
29 'format': 'bestvideo',
32 'url': 'http://parliamentlive.tv/event/index/3f24936f-130f-40bf-9a5d-b3d6479da6a4',
33 'only_matching': True,
36 def _real_extract(self
, url
):
37 video_id
= self
._match
_id
(url
)
38 video_info
= self
._download
_json
(f
'https://www.parliamentlive.tv/Event/GetShareVideo/{video_id}', video_id
)
39 _DEVICE_ID
= str(uuid
.uuid4())
40 auth
= 'Bearer ' + self
._download
_json
(
41 'https://exposure.api.redbee.live/v2/customer/UKParliament/businessunit/ParliamentLive/auth/anonymous',
43 'Origin': 'https://videoplayback.parliamentlive.tv',
44 'Accept': 'application/json, text/plain, */*',
45 'Content-Type': 'application/json;charset=utf-8'
47 'deviceId': _DEVICE_ID
,
49 'deviceId': _DEVICE_ID
,
53 'name': ' Mozilla Firefox 91'
55 }).encode('utf-8'))['sessionToken']
57 video_urls
= self
._download
_json
(
58 f
'https://exposure.api.redbee.live/v2/customer/UKParliament/businessunit/ParliamentLive/entitlement/{video_id}/play',
59 video_id
, headers
={'Authorization': auth, 'Accept': 'application/json, text/plain, */*'}
)['formats']
62 for format
in video_urls
:
63 if not format
.get('mediaLocator'):
65 if format
.get('format') == 'DASH':
66 formats
.extend(self
._extract
_mpd
_formats
(
67 format
['mediaLocator'], video_id
, mpd_id
='dash', fatal
=False))
68 elif format
.get('format') == 'SMOOTHSTREAMING':
69 formats
.extend(self
._extract
_ism
_formats
(
70 format
['mediaLocator'], video_id
, ism_id
='ism', fatal
=False))
71 elif format
.get('format') == 'HLS':
72 formats
.extend(self
._extract
_m
3u8_formats
(
73 format
['mediaLocator'], video_id
, m3u8_id
='hls', fatal
=False))
75 self
._sort
_formats
(formats
)
80 'title': video_info
['event']['title'],
81 'timestamp': unified_timestamp(try_get(video_info
, lambda x
: x
['event']['publishedStartTime'])),
82 'thumbnail': video_info
.get('thumbnailUrl'),