1 from .brightcove
import BrightcoveNewIE
2 from .common
import InfoExtractor
3 from ..utils
import ExtractorError
, traverse_obj
6 class OneNewsNZIE(InfoExtractor
):
8 IE_DESC
= '1news.co.nz article videos'
9 _VALID_URL
= r
'https?://(?:www\.)?(?:1|one)news\.co\.nz/\d+/\d+/\d+/(?P<id>[^/?#&]+)'
12 'url': 'https://www.1news.co.nz/2022/09/29/cows-painted-green-on-parliament-lawn-in-climate-protest/',
14 'id': 'cows-painted-green-on-parliament-lawn-in-climate-protest',
15 'title': '\'Cows\' painted green on Parliament lawn in climate protest',
19 'id': '6312993358112',
20 'title': 'Activists dressed as cows painted green outside Parliament in climate protest',
23 'uploader_id': '963482464001',
24 'timestamp': 1664416255,
25 'upload_date': '20220929',
27 'thumbnail': r
're:^https?://.*\.jpg$',
28 'description': 'Greenpeace accused the Government of "greenwashing" instead of taking climate action.',
33 'url': 'https://www.1news.co.nz/2022/09/30/now-is-the-time-to-care-about-womens-rugby/',
35 'id': 'now-is-the-time-to-care-about-womens-rugby',
36 'title': 'Now is the time to care about women\'s rugby',
41 'title': 'Why I love women’s rugby: Black Fern Ruahei Demant',
43 'channel_follower_count': int,
44 'channel_url': 'https://www.youtube.com/channel/UC2BQ3U9IxoYIJyulv0bN5PQ',
46 'uploader': 'Re: News',
47 'upload_date': '20211215',
48 'uploader_id': 'UC2BQ3U9IxoYIJyulv0bN5PQ',
49 'uploader_url': 'http://www.youtube.com/channel/UC2BQ3U9IxoYIJyulv0bN5PQ',
50 'channel_id': 'UC2BQ3U9IxoYIJyulv0bN5PQ',
51 'channel': 'Re: News',
53 'thumbnail': 'https://i.ytimg.com/vi/s4wEB9neTfU/maxresdefault.jpg',
56 'categories': ['Sports'],
58 'description': 'md5:8874410e5740ed1d8fd0df839f849813',
59 'availability': 'public',
60 'playable_in_embed': True,
61 'live_status': 'not_live',
66 'url': 'https://www.1news.co.nz/2022/09/29/raw-videos-capture-hurricane-ians-fury-as-it-slams-florida/',
68 'id': 'raw-videos-capture-hurricane-ians-fury-as-it-slams-florida',
69 'title': 'Raw videos capture Hurricane Ian\'s fury as it slams Florida',
71 'playlist_mincount': 2,
73 'url': 'https://www.onenews.co.nz/2022/09/29/cows-painted-green-on-parliament-lawn-in-climate-protest/',
74 'only_matching': True,
77 BRIGHTCOVE_URL_TEMPLATE
= 'http://players.brightcove.net/%s/0xpHIR6IB_default/index.html?videoId=%s'
79 def _real_extract(self
, url
):
80 display_id
= self
._match
_id
(url
)
81 webpage
= self
._download
_webpage
(url
, display_id
)
83 fusion_metadata
= self
._search
_json
(r
'Fusion\.globalContent\s*=', webpage
, 'fusion metadata', display_id
)
86 for item
in traverse_obj(fusion_metadata
, 'content_elements') or []:
87 item_type
= traverse_obj(item
, 'subtype')
88 if item_type
== 'video':
89 brightcove_config
= traverse_obj(item
, ('embed', 'config'))
90 brightcove_url
= self
.BRIGHTCOVE_URL_TEMPLATE
% (
91 traverse_obj(brightcove_config
, 'brightcoveAccount') or '963482464001',
92 traverse_obj(brightcove_config
, 'brightcoveVideoId'),
94 entries
.append(self
.url_result(brightcove_url
, BrightcoveNewIE
))
95 elif item_type
== 'youtube':
96 video_id_or_url
= traverse_obj(item
, ('referent', 'id'), ('raw_oembed', '_id'))
98 entries
.append(self
.url_result(video_id_or_url
, ie
='Youtube'))
101 raise ExtractorError('This article does not have a video.', expected
=True)
104 traverse_obj(fusion_metadata
, ('headlines', 'basic'))
105 or self
._generic
_title
('', webpage
)
107 return self
.playlist_result(entries
, display_id
, playlist_title
)