1
0
Fork 0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2025-03-09 12:50:23 -05:00

support --no-playlist, hardcode subtitle ext vtt

This commit is contained in:
grqx_wsl 2024-12-26 01:05:44 +13:00
parent 81db00bf84
commit 1394bf22ad

View file

@ -5,7 +5,6 @@
strip_or_none, strip_or_none,
traverse_obj, traverse_obj,
url_or_none, url_or_none,
urlhandle_detect_ext,
urljoin, urljoin,
) )
@ -90,15 +89,19 @@ class NZOnScreenIE(InfoExtractor):
'height': 360, 'height': 360,
'width': 640, 'width': 640,
'subtitles': { 'subtitles': {
'en': [{'ext': 'SRT', 'data': 'md5:c2469f71020a32e55e228b532ded908f'}], 'en': [{'ext': 'vtt', 'url': 'https://www.nzonscreen.com/captions/3367'}],
}, },
'title': 'Reluctant Hero (clip 1)', 'title': 'Reluctant Hero (clip 1)',
'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': {'writesubtitles': True}, 'params': {
# 'writesubtitles': True,
'noplaylist': True,
},
}] }]
def _extract_formats(self, playlist): def _extract_formats(self, playlist):
@ -122,13 +125,6 @@ def _extract_formats(self, playlist):
})) }))
return formats return formats
def _get_subtitles(self, playinfo, video_id):
if caption := traverse_obj(playinfo, ('h264', 'caption_url')):
subtitle, urlh = self._download_webpage_handle(
urljoin('https://www.nzonscreen.com', caption), video_id, 'Downloading subtitles')
if subtitle:
return {'en': [{'ext': urlhandle_detect_ext(urlh), 'data': subtitle}]}
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)
@ -139,6 +135,9 @@ def _real_extract(self, url):
f'https://www.nzonscreen.com/html5/video_data/{video_id}', video_id, f'https://www.nzonscreen.com/html5/video_data/{video_id}', video_id,
'Downloading media data') 'Downloading media data')
if not self._yes_playlist(video_id, video_id):
del playlist[1:]
return self.playlist_result([{ return self.playlist_result([{
'alt_title': title if len(playlist) == 1 else None, 'alt_title': title if len(playlist) == 1 else None,
'display_id': video_id, 'display_id': video_id,
@ -146,7 +145,10 @@ def _real_extract(self, url):
'Referer': 'https://www.nzonscreen.com/', 'Referer': 'https://www.nzonscreen.com/',
'Origin': 'https://www.nzonscreen.com/', 'Origin': 'https://www.nzonscreen.com/',
}, },
'subtitles': self.extract_subtitles(playinfo, video_id), 'subtitles': {'en': [{
'url': traverse_obj(playinfo, ('h264', 'caption_url', {urljoin('https://www.nzonscreen.com')})),
'ext': 'vtt',
}]},
**traverse_obj(playinfo, { **traverse_obj(playinfo, {
'formats': {self._extract_formats}, 'formats': {self._extract_formats},
'id': 'uuid', 'id': 'uuid',