mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-20 09:52:50 +01:00
[NZOnScreenIE] Fix extractor
This commit is contained in:
parent
a7d3235c84
commit
f0cea43cde
@ -1,8 +1,8 @@
|
|||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
|
determine_ext,
|
||||||
float_or_none,
|
float_or_none,
|
||||||
int_or_none,
|
int_or_none,
|
||||||
remove_end,
|
|
||||||
strip_or_none,
|
strip_or_none,
|
||||||
traverse_obj,
|
traverse_obj,
|
||||||
url_or_none,
|
url_or_none,
|
||||||
@ -15,12 +15,12 @@ class NZOnScreenIE(InfoExtractor):
|
|||||||
'url': 'https://www.nzonscreen.com/title/shoop-shoop-diddy-wop-cumma-cumma-wang-dang-1982',
|
'url': 'https://www.nzonscreen.com/title/shoop-shoop-diddy-wop-cumma-cumma-wang-dang-1982',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': '726ed6585c6bfb30',
|
'id': '726ed6585c6bfb30',
|
||||||
'ext': 'mp4',
|
'ext': 'm3u8',
|
||||||
'format_id': 'hi',
|
'format_id': 'hd',
|
||||||
'display_id': 'shoop-shoop-diddy-wop-cumma-cumma-wang-dang-1982',
|
'display_id': 'shoop-shoop-diddy-wop-cumma-cumma-wang-dang-1982',
|
||||||
'title': 'Monte Video - "Shoop Shoop, Diddy Wop"',
|
'title': 'Monte Video - "Shoop Shoop, Diddy Wop"',
|
||||||
'description': 'Monte Video - "Shoop Shoop, Diddy Wop"',
|
'description': 'Monte Video - "Shoop Shoop, Diddy Wop"',
|
||||||
'alt_title': 'Shoop Shoop Diddy Wop Cumma Cumma Wang Dang | Music Video',
|
'alt_title': 'Shoop Shoop Diddy Wop Cumma Cumma Wang Dang',
|
||||||
'thumbnail': r're:https://www\.nzonscreen\.com/content/images/.+\.jpg',
|
'thumbnail': r're:https://www\.nzonscreen\.com/content/images/.+\.jpg',
|
||||||
'duration': 158,
|
'duration': 158,
|
||||||
},
|
},
|
||||||
@ -29,12 +29,12 @@ class NZOnScreenIE(InfoExtractor):
|
|||||||
'url': 'https://www.nzonscreen.com/title/shes-a-mod-1964?collection=best-of-the-60s',
|
'url': 'https://www.nzonscreen.com/title/shes-a-mod-1964?collection=best-of-the-60s',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': '3dbe709ff03c36f1',
|
'id': '3dbe709ff03c36f1',
|
||||||
'ext': 'mp4',
|
'ext': 'm3u8',
|
||||||
'format_id': 'hi',
|
'format_id': 'hd',
|
||||||
'display_id': 'shes-a-mod-1964',
|
'display_id': 'shes-a-mod-1964',
|
||||||
'title': 'Ray Columbus - \'She\'s A Mod\'',
|
'title': 'Ray Columbus - \'She\'s A Mod\'',
|
||||||
'description': 'Ray Columbus - \'She\'s A Mod\'',
|
'description': 'Ray Columbus - \'She\'s A Mod\'',
|
||||||
'alt_title': 'She\'s a Mod | Music Video',
|
'alt_title': 'She\'s a Mod',
|
||||||
'thumbnail': r're:https://www\.nzonscreen\.com/content/images/.+\.jpg',
|
'thumbnail': r're:https://www\.nzonscreen\.com/content/images/.+\.jpg',
|
||||||
'duration': 130,
|
'duration': 130,
|
||||||
},
|
},
|
||||||
@ -43,51 +43,78 @@ class NZOnScreenIE(InfoExtractor):
|
|||||||
'url': 'https://www.nzonscreen.com/title/puha-and-pakeha-1968/overview',
|
'url': 'https://www.nzonscreen.com/title/puha-and-pakeha-1968/overview',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': 'f86342544385ad8a',
|
'id': 'f86342544385ad8a',
|
||||||
'ext': 'mp4',
|
'ext': 'm3u8',
|
||||||
'format_id': 'hi',
|
'format_id': 'hd',
|
||||||
'display_id': 'puha-and-pakeha-1968',
|
'display_id': 'puha-and-pakeha-1968',
|
||||||
'title': 'Looking At New Zealand - Puha and Pakeha',
|
'title': 'Looking At New Zealand - Puha and Pakeha',
|
||||||
'alt_title': 'Looking at New Zealand - \'Pūhā and Pākehā\' | Television',
|
'alt_title': 'Looking at New Zealand - \'Pūhā and Pākehā\'',
|
||||||
'description': 'An excerpt from this television programme.',
|
'description': 'An excerpt from this television programme.',
|
||||||
'duration': 212,
|
'duration': 212,
|
||||||
'thumbnail': r're:https://www\.nzonscreen\.com/content/images/.+\.jpg',
|
'thumbnail': r're:https://www\.nzonscreen\.com/content/images/.+\.jpg',
|
||||||
},
|
},
|
||||||
'params': {'skip_download': 'm3u8'},
|
'params': {'skip_download': 'm3u8'},
|
||||||
|
}, {
|
||||||
|
'url': 'https://www.nzonscreen.com/title/flatmates-episode-one-1997',
|
||||||
|
'info_dict': {
|
||||||
|
'id': 'flatmates-episode-one-1997',
|
||||||
|
'title': 'Flatmates - 1, First Episode',
|
||||||
|
},
|
||||||
|
'playlist_count': 5,
|
||||||
}]
|
}]
|
||||||
|
|
||||||
def _extract_formats(self, playlist):
|
def _extract_formats(self, playlist):
|
||||||
for quality, (id_, url) in enumerate(traverse_obj(
|
for quality, (id_, url) in enumerate(traverse_obj(
|
||||||
playlist, ('h264', {'lo': 'lo_res', 'hi': 'hi_res'}), expected_type=url_or_none).items()):
|
playlist, ('h264', {'lo': 'lo_res', 'hi': 'hi_res', 'hd': 'hd_res'}), expected_type=url_or_none).items()):
|
||||||
yield {
|
yield {
|
||||||
'url': url,
|
'url': url,
|
||||||
'format_id': id_,
|
'format_id': id_,
|
||||||
'ext': 'mp4',
|
'ext': determine_ext(url),
|
||||||
'quality': quality,
|
'quality': quality,
|
||||||
'height': int_or_none(playlist.get('height')) if id_ == 'hi' else None,
|
'height': int_or_none(playlist.get('height')) if id_ == 'hd' else None,
|
||||||
'width': int_or_none(playlist.get('width')) if id_ == 'hi' else None,
|
'width': int_or_none(playlist.get('width')) if id_ == 'hd' else None,
|
||||||
'filesize_approx': float_or_none(traverse_obj(playlist, ('h264', f'{id_}_res_mb')), invscale=1024**2),
|
'filesize_approx': float_or_none(traverse_obj(playlist, ('h264', f'{id_}_res_mb')), invscale=1024**2),
|
||||||
}
|
}
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
video_id = self._match_id(url)
|
video_id = self._match_id(url)
|
||||||
webpage = self._download_webpage(url, video_id)
|
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, 'media data')
|
||||||
|
|
||||||
playlist = self._parse_json(self._html_search_regex(
|
if len(playlist) == 1:
|
||||||
r'data-video-config=\'([^\']+)\'', webpage, 'media data'), video_id)
|
playinfo = playlist[0]
|
||||||
|
return {
|
||||||
return {
|
'alt_title': title,
|
||||||
'id': playlist['uuid'],
|
'display_id': video_id,
|
||||||
'display_id': video_id,
|
'formats': list(self._extract_formats(playinfo)),
|
||||||
'title': strip_or_none(playlist.get('label')),
|
'http_headers': {
|
||||||
'description': strip_or_none(playlist.get('description')),
|
'Referer': 'https://www.nzonscreen.com/',
|
||||||
'alt_title': strip_or_none(remove_end(
|
'Origin': 'https://www.nzonscreen.com/',
|
||||||
self._html_extract_title(webpage, default=None) or self._og_search_title(webpage),
|
},
|
||||||
' | NZ On Screen')),
|
**traverse_obj(playinfo, {
|
||||||
'thumbnail': traverse_obj(playlist, ('thumbnail', 'path')),
|
'id': ('uuid'),
|
||||||
'duration': float_or_none(playlist.get('duration')),
|
'title': ('label', {strip_or_none}),
|
||||||
'formats': list(self._extract_formats(playlist)),
|
'description': ('description', {strip_or_none}),
|
||||||
'http_headers': {
|
'thumbnail': ('thumbnail', 'path'),
|
||||||
'Referer': 'https://www.nzonscreen.com/',
|
'duration': ('duration', {float_or_none}),
|
||||||
'Origin': 'https://www.nzonscreen.com/',
|
}),
|
||||||
},
|
}
|
||||||
}
|
else:
|
||||||
|
return self.playlist_result([{
|
||||||
|
'display_id': video_id,
|
||||||
|
'formats': list(self._extract_formats(playinfo)),
|
||||||
|
'http_headers': {
|
||||||
|
'Referer': 'https://www.nzonscreen.com/',
|
||||||
|
'Origin': 'https://www.nzonscreen.com/',
|
||||||
|
},
|
||||||
|
**traverse_obj(playinfo, {
|
||||||
|
'id': ('uuid'),
|
||||||
|
'title': ('label', {strip_or_none}),
|
||||||
|
'description': ('description', {strip_or_none}),
|
||||||
|
'thumbnail': ('thumbnail', 'path'),
|
||||||
|
'duration': ('duration', {float_or_none}),
|
||||||
|
}),
|
||||||
|
} for playinfo in playlist], video_id, title)
|
||||||
|
Loading…
Reference in New Issue
Block a user