code review

pull/10962/head
grqx_wsl 4 weeks ago
parent 252c9011bf
commit 4b87b7f6bd

@ -95,7 +95,6 @@ class NZOnScreenIE(InfoExtractor):
'description': 'Part one of four from this full length documentary.', 'description': 'Part one of four from this full length documentary.',
'display_id': 'reluctant-hero-2008', 'display_id': 'reluctant-hero-2008',
'duration': 1108.0, 'duration': 1108.0,
'alt_title': 'Reluctant Hero',
'thumbnail': r're:https://www\.nzonscreen\.com/content/images/.+\.jpg', 'thumbnail': r're:https://www\.nzonscreen\.com/content/images/.+\.jpg',
}, },
'params': {'noplaylist': True}, 'params': {'noplaylist': True},
@ -122,36 +121,41 @@ class NZOnScreenIE(InfoExtractor):
})) }))
return formats return formats
def _real_extract(self, url): def _extract_from_api_resp(self, vid_info, is_single_vid, title, video_id):
video_id = self._match_id(url) return {
webpage = self._download_webpage(url, video_id) 'alt_title': title if is_single_vid else None,
title = strip_or_none((
self._html_extract_title(webpage, default=None)
or self._og_search_title(webpage)).rsplit('|', 2)[0])
playlist = self._download_json(
f'https://www.nzonscreen.com/html5/video_data/{video_id}', video_id,
'Downloading media data')
if not self._yes_playlist(video_id, video_id):
del playlist[1:]
return self.playlist_result([{
'alt_title': title if len(playlist) == 1 else None,
'display_id': video_id, 'display_id': video_id,
'http_headers': { 'http_headers': {
'Referer': 'https://www.nzonscreen.com/', 'Referer': 'https://www.nzonscreen.com/',
'Origin': 'https://www.nzonscreen.com/', 'Origin': 'https://www.nzonscreen.com/',
}, },
'subtitles': {'en': [{ 'subtitles': {'en': [{
'url': traverse_obj(playinfo, ('h264', 'caption_url', {urljoin('https://www.nzonscreen.com')})), 'url': traverse_obj(vid_info, ('h264', 'caption_url', {urljoin('https://www.nzonscreen.com')})),
'ext': 'vtt', 'ext': 'vtt',
}]}, }]},
'formats': self._extract_formats(playinfo), 'formats': self._extract_formats(vid_info),
**traverse_obj(playinfo, { **traverse_obj(vid_info, {
'id': 'uuid', 'id': 'uuid',
'title': ('label', {strip_or_none}), 'title': ('label', {strip_or_none}),
'description': ('description', {strip_or_none}), 'description': ('description', {strip_or_none}),
'thumbnail': ('thumbnail', 'path'), 'thumbnail': ('thumbnail', 'path'),
'duration': ('duration', {float_or_none}), 'duration': ('duration', {float_or_none}),
}), }),
} for playinfo in playlist], video_id, title) }
def _real_extract(self, url):
video_id = self._match_id(url)
webpage = self._download_webpage(url, video_id)
title = strip_or_none((
self._html_extract_title(webpage, default=None)
or self._og_search_title(webpage)).rsplit('|', 2)[0])
playlist = self._download_json(
f'https://www.nzonscreen.com/html5/video_data/{video_id}', video_id,
'Downloading media data')
if self._yes_playlist(video_id, traverse_obj(playlist, (0, 'id'))):
return self.playlist_result(
[self._extract_from_api_resp(vid_info, len(playlist) == 1, title, video_id) for vid_info in playlist],
playlist_id=video_id, playlist_title=title)
return self._extract_from_api_resp(playlist[0], len(playlist) == 1, title, video_id)

Loading…
Cancel
Save