3 from .common
import InfoExtractor
7 get_elements_html_by_class
,
10 from ..utils
.traversal
import traverse_obj
13 class GBNewsIE(InfoExtractor
):
14 IE_DESC
= 'GB News clips, features and live streams'
15 _VALID_URL
= r
'https?://(?:www\.)?gbnews\.(?:uk|com)/(?:\w+/)?(?P<id>[^#?]+)'
18 _SSMP_URL
= 'https://mm-v2.simplestream.com/ssmp/api.php'
20 'url': 'https://www.gbnews.com/news/bbc-claudine-gay-harvard-university-antisemitism-row',
24 'thumbnail': r
're:https?://www\.gbnews\.\w+/.+\.(?:jpe?g|png|webp)',
25 'display_id': 'bbc-claudine-gay-harvard-university-antisemitism-row',
26 'description': 'The post was criticised by former employers of the broadcaster',
27 'title': 'BBC deletes post after furious backlash over headline downplaying antisemitism',
30 'url': 'https://www.gbnews.com/royal/prince-harry-in-love-with-kate-meghan-markle-jealous-royal',
34 'thumbnail': r
're:https?://www\.gbnews\.\w+/.+\.(?:jpe?g|png|webp)',
35 'display_id': 'prince-harry-in-love-with-kate-meghan-markle-jealous-royal',
36 'description': 'Ingrid Seward has published 17 books documenting the highs and lows of the Royal Family',
37 'title': 'Royal author claims Prince Harry was \'in love\' with Kate - Meghan was \'jealous\'',
40 'url': 'https://www.gbnews.uk/watchlive',
44 'thumbnail': r
're:https?://www\.gbnews\.\w+/.+\.(?:jpe?g|png|webp)',
45 'display_id': 'watchlive',
46 'live_status': 'is_live',
47 'title': r
're:^GB News Live',
49 'params': {'skip_download': 'm3u8'}
,
53 def _get_ss_endpoint(self
, data_id
, data_env
):
57 data_env
= 'production'
59 json_data
= self
._download
_json
(
60 self
._SSMP
_URL
, None, 'Downloading Simplestream JSON metadata', query
={
64 meta_url
= traverse_obj(json_data
, ('response', 'api_hostname', {url_or_none}
))
66 raise ExtractorError('No API host found')
70 def _real_extract(self
, url
):
71 display_id
= self
._match
_id
(url
).rpartition('/')[2]
72 webpage
= self
._download
_webpage
(url
, display_id
)
75 elements
= get_elements_html_by_class('simplestream', webpage
)
76 for html_tag
in elements
:
77 attributes
= extract_attributes(html_tag
)
78 if 'sidebar' not in (attributes
.get('class') or ''):
79 video_data
= attributes
81 raise ExtractorError('Could not find video element', expected
=True)
83 endpoint_url
= self
._get
_ss
_endpoint
(video_data
.get('data-id'), video_data
.get('data-env'))
85 uvid
= video_data
['data-uvid']
86 video_type
= video_data
.get('data-type')
87 if not video_type
or video_type
== 'vod':
89 stream_data
= self
._download
_json
(
90 f
'{endpoint_url}/api/{video_type}/stream/{uvid}',
91 uvid
, 'Downloading stream JSON', query
={
92 'key': video_data
.get('data-key'),
93 'platform': self
._PLATFORM
,
95 if traverse_obj(stream_data
, 'drm'):
100 'display_id': display_id
,
101 'title': self
._og
_search
_title
(webpage
, default
=None),
102 'description': self
._og
_search
_description
(webpage
, default
=None),
103 'formats': self
._extract
_m
3u8_formats
(traverse_obj(stream_data
, (
104 'response', 'stream', {url_or_none}
)), uvid
, 'mp4'),
105 'thumbnail': self
._og
_search
_thumbnail
(webpage
, default
=None),
106 'is_live': video_type
== 'live',