mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-12-14 14:46:50 +01:00
[extractor/twitter:spaces] Fix extraction (#7512)
Closes #7455 Authored by: bashonly
This commit is contained in:
parent
3b7f5300c5
commit
1cffd621cb
@ -889,8 +889,10 @@ class TwitterIE(TwitterBaseIE):
|
|||||||
'uploader_id': 'MoniqueCamarra',
|
'uploader_id': 'MoniqueCamarra',
|
||||||
'live_status': 'was_live',
|
'live_status': 'was_live',
|
||||||
'release_timestamp': 1658417414,
|
'release_timestamp': 1658417414,
|
||||||
'description': 'md5:acce559345fd49f129c20dbcda3f1201',
|
'description': 'md5:4dc8e972f1d8b3c6580376fabb02a3ad',
|
||||||
'timestamp': 1658407771464,
|
'timestamp': 1658407771,
|
||||||
|
'release_date': '20220721',
|
||||||
|
'upload_date': '20220721',
|
||||||
},
|
},
|
||||||
'add_ie': ['TwitterSpaces'],
|
'add_ie': ['TwitterSpaces'],
|
||||||
'params': {'skip_download': 'm3u8'},
|
'params': {'skip_download': 'm3u8'},
|
||||||
@ -1436,7 +1438,10 @@ class TwitterSpacesIE(TwitterBaseIE):
|
|||||||
'uploader': r're:Lucio Di Gaetano.*?',
|
'uploader': r're:Lucio Di Gaetano.*?',
|
||||||
'uploader_id': 'luciodigaetano',
|
'uploader_id': 'luciodigaetano',
|
||||||
'live_status': 'was_live',
|
'live_status': 'was_live',
|
||||||
'timestamp': 1659877956397,
|
'timestamp': 1659877956,
|
||||||
|
'upload_date': '20220807',
|
||||||
|
'release_timestamp': 1659904215,
|
||||||
|
'release_date': '20220807',
|
||||||
},
|
},
|
||||||
'params': {'skip_download': 'm3u8'},
|
'params': {'skip_download': 'm3u8'},
|
||||||
}]
|
}]
|
||||||
@ -1482,26 +1487,31 @@ def _real_extract(self, url):
|
|||||||
|
|
||||||
metadata = space_data['metadata']
|
metadata = space_data['metadata']
|
||||||
live_status = try_call(lambda: self.SPACE_STATUS[metadata['state'].lower()])
|
live_status = try_call(lambda: self.SPACE_STATUS[metadata['state'].lower()])
|
||||||
|
is_live = live_status == 'is_live'
|
||||||
|
|
||||||
formats = []
|
formats = []
|
||||||
if live_status == 'is_upcoming':
|
if live_status == 'is_upcoming':
|
||||||
self.raise_no_formats('Twitter Space not started yet', expected=True)
|
self.raise_no_formats('Twitter Space not started yet', expected=True)
|
||||||
elif live_status == 'post_live':
|
elif not is_live and not metadata.get('is_space_available_for_replay'):
|
||||||
self.raise_no_formats('Twitter Space ended but not downloadable yet', expected=True)
|
self.raise_no_formats('Twitter Space ended and replay is disabled', expected=True)
|
||||||
else:
|
elif metadata.get('media_key'):
|
||||||
source = self._call_api(
|
source = traverse_obj(
|
||||||
f'live_video_stream/status/{metadata["media_key"]}', metadata['media_key'])['source']
|
self._call_api(f'live_video_stream/status/{metadata["media_key"]}', metadata['media_key']),
|
||||||
|
('source', ('noRedirectPlaybackUrl', 'location'), {url_or_none}), get_all=False)
|
||||||
# XXX: Native downloader does not work
|
|
||||||
formats = self._extract_m3u8_formats(
|
formats = self._extract_m3u8_formats(
|
||||||
traverse_obj(source, 'noRedirectPlaybackUrl', 'location'),
|
source, metadata['media_key'], 'm4a', live=is_live, fatal=False,
|
||||||
metadata['media_key'], 'm4a', 'm3u8', live=live_status == 'is_live',
|
headers={'Referer': 'https://twitter.com/'}) if source else []
|
||||||
headers={'Referer': 'https://twitter.com/'})
|
|
||||||
for fmt in formats:
|
for fmt in formats:
|
||||||
fmt.update({'vcodec': 'none', 'acodec': 'aac'})
|
fmt.update({'vcodec': 'none', 'acodec': 'aac'})
|
||||||
|
if not is_live:
|
||||||
|
fmt['container'] = 'm4a_dash'
|
||||||
|
|
||||||
participants = ', '.join(traverse_obj(
|
participants = ', '.join(traverse_obj(
|
||||||
space_data, ('participants', 'speakers', ..., 'display_name'))) or 'nobody yet'
|
space_data, ('participants', 'speakers', ..., 'display_name'))) or 'nobody yet'
|
||||||
|
|
||||||
|
if not formats and live_status == 'post_live':
|
||||||
|
self.raise_no_formats('Twitter Space ended but not downloadable yet', expected=True)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'id': space_id,
|
'id': space_id,
|
||||||
'title': metadata.get('title'),
|
'title': metadata.get('title'),
|
||||||
@ -1513,7 +1523,7 @@ def _real_extract(self, url):
|
|||||||
'live_status': live_status,
|
'live_status': live_status,
|
||||||
'release_timestamp': try_call(
|
'release_timestamp': try_call(
|
||||||
lambda: int_or_none(metadata['scheduled_start'], scale=1000)),
|
lambda: int_or_none(metadata['scheduled_start'], scale=1000)),
|
||||||
'timestamp': metadata.get('created_at'),
|
'timestamp': int_or_none(metadata.get('created_at'), scale=1000),
|
||||||
'formats': formats,
|
'formats': formats,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user