mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-07 20:30:41 -05:00
Slight refactor
This commit is contained in:
parent
0eedb14342
commit
d2ab253266
1 changed files with 27 additions and 8 deletions
|
@ -24,23 +24,42 @@ class BeaconTvIE(InfoExtractor):
|
||||||
'timestamp': 1715227200,
|
'timestamp': 1715227200,
|
||||||
'duration': 105.494,
|
'duration': 105.494,
|
||||||
},
|
},
|
||||||
|
}, {
|
||||||
|
'url': 'https://beacon.tv/content/re-slayers-take-trailer',
|
||||||
|
'md5': 'd879b091485dbed2245094c8152afd89',
|
||||||
|
'info_dict': {
|
||||||
|
'id': 're-slayers-take-trailer',
|
||||||
|
'ext': 'mp4',
|
||||||
|
'title': 'The Re-Slayer’s Take | Official Trailer',
|
||||||
|
'timestamp': 1715189040,
|
||||||
|
'upload_date': '20240508',
|
||||||
|
'duration': 53.249,
|
||||||
|
'thumbnail': 'https://cdn.jwplayer.com/v2/media/PW5ApIw3/poster.jpg?width=720',
|
||||||
|
},
|
||||||
}]
|
}]
|
||||||
|
|
||||||
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)
|
||||||
|
|
||||||
state = self._search_nextjs_data(webpage, video_id)['props']['pageProps']['__APOLLO_STATE__']
|
content_data = traverse_obj(self._search_nextjs_data(webpage, video_id), (
|
||||||
|
'props', 'pageProps', '__APOLLO_STATE__',
|
||||||
|
lambda k, v: k.startswith('Content:') and v['slug'] == video_id, any))
|
||||||
|
if not content_data:
|
||||||
|
raise ExtractorError('Failed to extract content data')
|
||||||
|
|
||||||
content_data = traverse_obj(state, (lambda k, v: k.startswith('Content:') and v['slug'] == video_id, any))
|
jwplayer_data = traverse_obj(content_data, (
|
||||||
|
(('contentVideo', 'video', 'videoData'),
|
||||||
if not content_data or not content_data.get('contentVideo'):
|
('contentPodcast', 'podcast', 'audioData')), {json.loads}, {dict}, any))
|
||||||
raise ExtractorError(
|
if not jwplayer_data:
|
||||||
'Failed to extract video. Either the given content is not a video, or it requires authentication', expected=True)
|
if content_data.get('contentType') not in ('videoPodcast', 'video', 'podcast'):
|
||||||
|
raise ExtractorError('Content is not a video/podcast', expected=True)
|
||||||
|
if traverse_obj(content_data, ('contentTier', '__ref')) != 'MemberTier:65b258d178f89be87b4dc0a4':
|
||||||
|
self.raise_login_required('This video/podcast is for members only')
|
||||||
|
raise ExtractorError('Failed to extract content')
|
||||||
|
|
||||||
return {
|
return {
|
||||||
**self._parse_jwplayer_data(traverse_obj(
|
**self._parse_jwplayer_data(jwplayer_data, video_id),
|
||||||
content_data, ('contentVideo', 'video', 'videoData', {json.loads})), video_id),
|
|
||||||
**traverse_obj(content_data, {
|
**traverse_obj(content_data, {
|
||||||
'title': ('title', {str}),
|
'title': ('title', {str}),
|
||||||
'description': ('description', {str}),
|
'description': ('description', {str}),
|
||||||
|
|
Loading…
Reference in a new issue