1 from .common
import InfoExtractor
5 get_elements_html_by_class
,
8 from ..utils
.traversal
import traverse_obj
11 class GBNewsIE(InfoExtractor
):
12 IE_DESC
= 'GB News clips, features and live streams'
13 _VALID_URL
= r
'https?://(?:www\.)?gbnews\.(?:uk|com)/(?:\w+/)?(?P<id>[^#?]+)'
16 _SSMP_URL
= 'https://mm-v2.simplestream.com/ssmp/api.php'
18 'url': 'https://www.gbnews.com/news/bbc-claudine-gay-harvard-university-antisemitism-row',
22 'thumbnail': r
're:https?://www\.gbnews\.\w+/.+\.(?:jpe?g|png|webp)',
23 'display_id': 'bbc-claudine-gay-harvard-university-antisemitism-row',
24 'description': 'The post was criticised by former employers of the broadcaster',
25 'title': 'BBC deletes post after furious backlash over headline downplaying antisemitism',
28 'url': 'https://www.gbnews.com/royal/prince-harry-in-love-with-kate-meghan-markle-jealous-royal',
32 'thumbnail': r
're:https?://www\.gbnews\.\w+/.+\.(?:jpe?g|png|webp)',
33 'display_id': 'prince-harry-in-love-with-kate-meghan-markle-jealous-royal',
34 'description': 'Ingrid Seward has published 17 books documenting the highs and lows of the Royal Family',
35 'title': 'Royal author claims Prince Harry was \'in love\' with Kate - Meghan was \'jealous\'',
38 'url': 'https://www.gbnews.uk/watchlive',
42 'thumbnail': r
're:https?://www\.gbnews\.\w+/.+\.(?:jpe?g|png|webp)',
43 'display_id': 'watchlive',
44 'live_status': 'is_live',
45 'title': r
're:^GB News Live',
47 'params': {'skip_download': 'm3u8'},
51 def _get_ss_endpoint(self
, data_id
, data_env
):
52 if not self
._SS
_ENDPOINTS
:
53 self
._SS
_ENDPOINTS
= {}
58 data_env
= 'production'
59 key
= data_id
, data_env
60 result
= self
._SS
_ENDPOINTS
.get(key
)
64 json_data
= self
._download
_json
(
65 self
._SSMP
_URL
, None, 'Downloading Simplestream JSON metadata', query
={
69 meta_url
= traverse_obj(json_data
, ('response', 'api_hostname', {url_or_none}
))
71 raise ExtractorError('No API host found')
73 self
._SS
_ENDPOINTS
[key
] = meta_url
76 def _real_extract(self
, url
):
77 display_id
= self
._match
_id
(url
).rpartition('/')[2]
78 webpage
= self
._download
_webpage
(url
, display_id
)
81 elements
= get_elements_html_by_class('simplestream', webpage
)
82 for html_tag
in elements
:
83 attributes
= extract_attributes(html_tag
)
84 if 'sidebar' not in (attributes
.get('class') or ''):
85 video_data
= attributes
87 raise ExtractorError('Could not find video element', expected
=True)
89 endpoint_url
= self
._get
_ss
_endpoint
(video_data
.get('data-id'), video_data
.get('data-env'))
91 uvid
= video_data
['data-uvid']
92 video_type
= video_data
.get('data-type')
93 if not video_type
or video_type
== 'vod':
95 stream_data
= self
._download
_json
(
96 f
'{endpoint_url}/api/{video_type}/stream/{uvid}',
97 uvid
, 'Downloading stream JSON', query
={
98 'key': video_data
.get('data-key'),
99 'platform': self
._PLATFORM
,
101 if traverse_obj(stream_data
, 'drm'):
102 self
.report_drm(uvid
)
106 'display_id': display_id
,
107 'title': self
._og
_search
_title
(webpage
, default
=None),
108 'description': self
._og
_search
_description
(webpage
, default
=None),
109 'formats': self
._extract
_m
3u8_formats
(traverse_obj(stream_data
, (
110 'response', 'stream', {url_or_none}
)), uvid
, 'mp4'),
111 'thumbnail': self
._og
_search
_thumbnail
(webpage
, default
=None),
112 'is_live': video_type
== 'live',