mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-28 09:31:01 +01:00
[ie/twitter:broadcast] Support --wait-for-video
(#8475)
Closes #8473 Authored by: bashonly
This commit is contained in:
parent
2863fcf2b6
commit
f6e97090d2
@ -4,6 +4,7 @@
|
|||||||
parse_iso8601,
|
parse_iso8601,
|
||||||
unescapeHTML,
|
unescapeHTML,
|
||||||
)
|
)
|
||||||
|
from ..utils.traversal import traverse_obj
|
||||||
|
|
||||||
|
|
||||||
class PeriscopeBaseIE(InfoExtractor):
|
class PeriscopeBaseIE(InfoExtractor):
|
||||||
@ -20,8 +21,6 @@ def _parse_broadcast_data(self, broadcast, video_id):
|
|||||||
title = broadcast.get('status') or 'Periscope Broadcast'
|
title = broadcast.get('status') or 'Periscope Broadcast'
|
||||||
uploader = broadcast.get('user_display_name') or broadcast.get('username')
|
uploader = broadcast.get('user_display_name') or broadcast.get('username')
|
||||||
title = '%s - %s' % (uploader, title) if uploader else title
|
title = '%s - %s' % (uploader, title) if uploader else title
|
||||||
is_live = broadcast.get('state').lower() == 'running'
|
|
||||||
|
|
||||||
thumbnails = [{
|
thumbnails = [{
|
||||||
'url': broadcast[image],
|
'url': broadcast[image],
|
||||||
} for image in ('image_url', 'image_url_medium', 'image_url_small') if broadcast.get(image)]
|
} for image in ('image_url', 'image_url_medium', 'image_url_small') if broadcast.get(image)]
|
||||||
@ -31,12 +30,16 @@ def _parse_broadcast_data(self, broadcast, video_id):
|
|||||||
'title': title,
|
'title': title,
|
||||||
'timestamp': parse_iso8601(broadcast.get('created_at')) or int_or_none(
|
'timestamp': parse_iso8601(broadcast.get('created_at')) or int_or_none(
|
||||||
broadcast.get('created_at_ms'), scale=1000),
|
broadcast.get('created_at_ms'), scale=1000),
|
||||||
|
'release_timestamp': int_or_none(broadcast.get('scheduled_start_ms'), scale=1000),
|
||||||
'uploader': uploader,
|
'uploader': uploader,
|
||||||
'uploader_id': broadcast.get('user_id') or broadcast.get('username'),
|
'uploader_id': broadcast.get('user_id') or broadcast.get('username'),
|
||||||
'thumbnails': thumbnails,
|
'thumbnails': thumbnails,
|
||||||
'view_count': int_or_none(broadcast.get('total_watched')),
|
'view_count': int_or_none(broadcast.get('total_watched')),
|
||||||
'tags': broadcast.get('tags'),
|
'tags': broadcast.get('tags'),
|
||||||
'is_live': is_live,
|
'live_status': {
|
||||||
|
'running': 'is_live',
|
||||||
|
'not_started': 'is_upcoming',
|
||||||
|
}.get(traverse_obj(broadcast, ('state', {str.lower}))) or 'was_live'
|
||||||
}
|
}
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -1619,6 +1619,9 @@ def _real_extract(self, url):
|
|||||||
info['title'] = broadcast.get('status') or info.get('title')
|
info['title'] = broadcast.get('status') or info.get('title')
|
||||||
info['uploader_id'] = broadcast.get('twitter_username') or info.get('uploader_id')
|
info['uploader_id'] = broadcast.get('twitter_username') or info.get('uploader_id')
|
||||||
info['uploader_url'] = format_field(broadcast, 'twitter_username', 'https://twitter.com/%s', default=None)
|
info['uploader_url'] = format_field(broadcast, 'twitter_username', 'https://twitter.com/%s', default=None)
|
||||||
|
if info['live_status'] == 'is_upcoming':
|
||||||
|
return info
|
||||||
|
|
||||||
media_key = broadcast['media_key']
|
media_key = broadcast['media_key']
|
||||||
source = self._call_api(
|
source = self._call_api(
|
||||||
f'live_video_stream/status/{media_key}', media_key)['source']
|
f'live_video_stream/status/{media_key}', media_key)['source']
|
||||||
|
Loading…
Reference in New Issue
Block a user