mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2026-04-27 02:55:54 +00:00
Apply suggestions
This commit is contained in:
parent
b01b1f6806
commit
12acefdbce
@ -20,7 +20,6 @@ from ..utils import (
|
|||||||
remove_end,
|
remove_end,
|
||||||
str_or_none,
|
str_or_none,
|
||||||
strip_or_none,
|
strip_or_none,
|
||||||
traverse_obj,
|
|
||||||
truncate_string,
|
truncate_string,
|
||||||
try_call,
|
try_call,
|
||||||
try_get,
|
try_get,
|
||||||
@ -29,6 +28,7 @@ from ..utils import (
|
|||||||
url_or_none,
|
url_or_none,
|
||||||
xpath_text,
|
xpath_text,
|
||||||
)
|
)
|
||||||
|
from ..utils.traversal import require, traverse_obj
|
||||||
|
|
||||||
|
|
||||||
class TwitterBaseIE(InfoExtractor):
|
class TwitterBaseIE(InfoExtractor):
|
||||||
@ -1649,19 +1649,37 @@ class TwitterBroadcastIE(TwitterBaseIE, PeriscopeBaseIE):
|
|||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
'url': 'https://x.com/i/events/1910629646300762112',
|
'url': 'https://x.com/i/events/1910629646300762112',
|
||||||
'only_matching': True,
|
'info_dict': {
|
||||||
|
'id': '1LyxBWDRNqyKN',
|
||||||
|
'ext': 'mp4',
|
||||||
|
'title': '#ガンニバル ウォッチパーティー',
|
||||||
|
'concurrent_view_count': int,
|
||||||
|
'display_id': '1910629646300762112',
|
||||||
|
'live_status': 'was_live',
|
||||||
|
'tags': ['ガンニバル'],
|
||||||
|
'release_date': '20250423',
|
||||||
|
'release_timestamp': 1745409000,
|
||||||
|
'thumbnail': r're:https?://[^?#]+\.jpg\?token=',
|
||||||
|
'timestamp': 1745403328,
|
||||||
|
'upload_date': '20250423',
|
||||||
|
'uploader': 'ディズニープラス公式',
|
||||||
|
'uploader_id': 'DisneyPlusJP',
|
||||||
|
'uploader_url': 'https://twitter.com/DisneyPlusJP',
|
||||||
|
'view_count': int,
|
||||||
|
},
|
||||||
}]
|
}]
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
broadcast_type, broadcast_id = self._match_valid_url(url).groups()
|
broadcast_type, display_id = self._match_valid_url(url).groups()
|
||||||
|
|
||||||
if broadcast_type == 'events':
|
if broadcast_type == 'events':
|
||||||
if b_id := traverse_obj(self._call_api(
|
timeline = self._call_api(
|
||||||
f'live_event/1/{broadcast_id}/timeline.json', broadcast_id,
|
f'live_event/1/{display_id}/timeline.json', display_id)
|
||||||
), ('twitter_objects', 'broadcasts', ..., ('id', 'broadcast_id'), {str_or_none}, any)):
|
broadcast_id = traverse_obj(timeline, (
|
||||||
return self.url_result(
|
'twitter_objects', 'broadcasts', ..., ('id', 'broadcast_id'),
|
||||||
f'https://x.com/i/broadcasts/{b_id}', TwitterBroadcastIE)
|
{str_or_none}, any, {require('broadcast ID')}))
|
||||||
raise ExtractorError('No broadcast_id found', expected=True)
|
else:
|
||||||
|
broadcast_id = display_id
|
||||||
|
|
||||||
broadcast = self._call_api(
|
broadcast = self._call_api(
|
||||||
'broadcasts/show.json', broadcast_id,
|
'broadcasts/show.json', broadcast_id,
|
||||||
@ -1672,6 +1690,7 @@ class TwitterBroadcastIE(TwitterBaseIE, PeriscopeBaseIE):
|
|||||||
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)
|
||||||
|
info['display_id'] = display_id
|
||||||
if info['live_status'] == 'is_upcoming':
|
if info['live_status'] == 'is_upcoming':
|
||||||
return info
|
return info
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user