mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2025-08-14 16:38:29 +00:00
[twitter:spaces] Add downloader
cited 56ba5e11cc (diff-a949010439cefd1cf130901ae40a60fc3c33d3e191667b9fc8dc40a58d3e5310R271-R289)
by @ef1500
TODO: Rename the concatenated `.m4a` to `.aac` and then `FixupM4a`
This commit is contained in:
parent
23c658b9cb
commit
6a00da4cbe
@ -36,6 +36,7 @@ def get_suitable_downloader(info_dict, params={}, default=NO_DEFAULT, protocol=N
|
|||||||
from .websocket import WebSocketFragmentFD
|
from .websocket import WebSocketFragmentFD
|
||||||
from .youtube_live_chat import YoutubeLiveChatFD
|
from .youtube_live_chat import YoutubeLiveChatFD
|
||||||
from .bunnycdn import BunnyCdnFD
|
from .bunnycdn import BunnyCdnFD
|
||||||
|
from .twitter import TwitterSpacesFD
|
||||||
|
|
||||||
PROTOCOL_MAP = {
|
PROTOCOL_MAP = {
|
||||||
'rtmp': RtmpFD,
|
'rtmp': RtmpFD,
|
||||||
@ -56,6 +57,7 @@ def get_suitable_downloader(info_dict, params={}, default=NO_DEFAULT, protocol=N
|
|||||||
'youtube_live_chat': YoutubeLiveChatFD,
|
'youtube_live_chat': YoutubeLiveChatFD,
|
||||||
'youtube_live_chat_replay': YoutubeLiveChatFD,
|
'youtube_live_chat_replay': YoutubeLiveChatFD,
|
||||||
'bunnycdn': BunnyCdnFD,
|
'bunnycdn': BunnyCdnFD,
|
||||||
|
'twitter_spaces': TwitterSpacesFD,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
15
yt_dlp/downloader/twitter.py
Normal file
15
yt_dlp/downloader/twitter.py
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
from .hls import HlsFD
|
||||||
|
|
||||||
|
|
||||||
|
class TwitterSpacesFD(HlsFD):
|
||||||
|
FD_NAME = 'twitterspaces'
|
||||||
|
|
||||||
|
def _read_fragment(self, ctx):
|
||||||
|
frag_content = super()._read_fragment(ctx)
|
||||||
|
idx = frag_content.find(bytes(
|
||||||
|
[0x49, 0x44, 0x33, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0x50, 0x52, 0x49, 0x56]))
|
||||||
|
if idx > 0:
|
||||||
|
self.to_screen(f'[{self.FD_NAME}] Removing partial header ({idx} bytes)')
|
||||||
|
return frag_content[idx:]
|
||||||
|
else:
|
||||||
|
return frag_content
|
@ -1853,8 +1853,8 @@ def _real_extract(self, url):
|
|||||||
is_audio_space = source and 'audio-space' in source
|
is_audio_space = source and 'audio-space' in source
|
||||||
formats = self._extract_m3u8_formats(
|
formats = self._extract_m3u8_formats(
|
||||||
source, metadata['media_key'], 'm4a' if is_audio_space else 'mp4',
|
source, metadata['media_key'], 'm4a' if is_audio_space else 'mp4',
|
||||||
# XXX: Some audio-only Spaces need ffmpeg as downloader
|
# XXX: Some audio-only Spaces need to truncate heads of their fragments, not only ffmpeg as downloader
|
||||||
entry_protocol='m3u8' if is_audio_space else 'm3u8_native',
|
entry_protocol='twitter_spaces' if is_audio_space else 'm3u8_native',
|
||||||
live=is_live, headers=headers, fatal=False) if source else []
|
live=is_live, headers=headers, fatal=False) if source else []
|
||||||
if is_audio_space:
|
if is_audio_space:
|
||||||
for fmt in formats:
|
for fmt in formats:
|
||||||
|
Loading…
Reference in New Issue
Block a user