mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2025-03-09 12:50:23 -05:00
Add error handling
This commit is contained in:
parent
cf7c0e3347
commit
2c4b308cc0
1 changed files with 8 additions and 5 deletions
|
@ -44,16 +44,19 @@ class MagellanTVIE(InfoExtractor):
|
||||||
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)
|
||||||
data = traverse_obj(self._search_nextjs_data(webpage, video_id), (
|
context = self._search_nextjs_data(webpage, video_id)['props']['pageProps']['reactContext']
|
||||||
'props', 'pageProps', 'reactContext',
|
data = traverse_obj(context, ((('video', 'detail'), ('series', 'currentEpisode')), {dict}, any))
|
||||||
(('video', 'detail'), ('series', 'currentEpisode')), {dict}), get_all=False)
|
|
||||||
formats = []
|
formats, subtitles = [], {}
|
||||||
subtitles = {}
|
|
||||||
for url in set(traverse_obj(data, ((('manifests', ..., 'hls'), 'jwp_video_url'), {url_or_none}))):
|
for url in set(traverse_obj(data, ((('manifests', ..., 'hls'), 'jwp_video_url'), {url_or_none}))):
|
||||||
fmts, subs = self._extract_m3u8_formats_and_subtitles(
|
fmts, subs = self._extract_m3u8_formats_and_subtitles(
|
||||||
url, video_id, 'mp4', m3u8_id='hls', fatal=False)
|
url, video_id, 'mp4', m3u8_id='hls', fatal=False)
|
||||||
formats.extend(fmts)
|
formats.extend(fmts)
|
||||||
self._merge_subtitles(subs, target=subtitles)
|
self._merge_subtitles(subs, target=subtitles)
|
||||||
|
if not formats and (error := traverse_obj(context, ('errorDetailPage', 'errorMessage', {str}))):
|
||||||
|
if 'available in your country' in error:
|
||||||
|
self.raise_geo_restricted(msg=error)
|
||||||
|
self.raise_no_formats(f'{self.IE_NAME} said: {error}', expected=True)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
|
|
Loading…
Reference in a new issue