mirror of https://github.com/yt-dlp/yt-dlp
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
76 lines
2.1 KiB
Python
76 lines
2.1 KiB
Python
11 years ago
|
from __future__ import unicode_literals
|
||
|
|
||
4 years ago
|
from ..utils import (
|
||
|
determine_protocol,
|
||
|
)
|
||
|
|
||
|
|
||
|
def _get_real_downloader(info_dict, protocol=None, *args, **kwargs):
|
||
|
info_copy = info_dict.copy()
|
||
|
if protocol:
|
||
|
info_copy['protocol'] = protocol
|
||
|
return get_suitable_downloader(info_copy, *args, **kwargs)
|
||
|
|
||
|
|
||
|
# Some of these require _get_real_downloader
|
||
11 years ago
|
from .common import FileDownloader
|
||
4 years ago
|
from .dash import DashSegmentsFD
|
||
10 years ago
|
from .f4m import F4mFD
|
||
11 years ago
|
from .hls import HlsFD
|
||
|
from .http import HttpFD
|
||
|
from .rtmp import RtmpFD
|
||
9 years ago
|
from .rtsp import RtspFD
|
||
8 years ago
|
from .ism import IsmFD
|
||
4 years ago
|
from .niconico import NiconicoDmcFD
|
||
4 years ago
|
from .youtube_live_chat import YoutubeLiveChatReplayFD
|
||
9 years ago
|
from .external import (
|
||
|
get_external_downloader,
|
||
|
FFmpegFD,
|
||
|
)
|
||
11 years ago
|
|
||
10 years ago
|
PROTOCOL_MAP = {
|
||
|
'rtmp': RtmpFD,
|
||
9 years ago
|
'm3u8_native': HlsFD,
|
||
|
'm3u8': FFmpegFD,
|
||
9 years ago
|
'mms': RtspFD,
|
||
|
'rtsp': RtspFD,
|
||
10 years ago
|
'f4m': F4mFD,
|
||
10 years ago
|
'http_dash_segments': DashSegmentsFD,
|
||
8 years ago
|
'ism': IsmFD,
|
||
4 years ago
|
'niconico_dmc': NiconicoDmcFD,
|
||
4 years ago
|
'youtube_live_chat_replay': YoutubeLiveChatReplayFD,
|
||
10 years ago
|
}
|
||
11 years ago
|
|
||
10 years ago
|
|
||
4 years ago
|
def get_suitable_downloader(info_dict, params={}, default=HttpFD):
|
||
11 years ago
|
"""Get the downloader class that can handle the info dict."""
|
||
10 years ago
|
protocol = determine_protocol(info_dict)
|
||
|
info_dict['protocol'] = protocol
|
||
|
|
||
9 years ago
|
# if (info_dict.get('start_time') or info_dict.get('end_time')) and not info_dict.get('requested_formats') and FFmpegFD.can_download(info_dict):
|
||
9 years ago
|
# return FFmpegFD
|
||
9 years ago
|
|
||
10 years ago
|
external_downloader = params.get('external_downloader')
|
||
|
if external_downloader is not None:
|
||
|
ed = get_external_downloader(external_downloader)
|
||
9 years ago
|
if ed.can_download(info_dict):
|
||
10 years ago
|
return ed
|
||
|
|
||
4 years ago
|
if protocol.startswith('m3u8'):
|
||
|
if info_dict.get('is_live'):
|
||
|
return FFmpegFD
|
||
|
elif _get_real_downloader(info_dict, 'frag_urls', params, None):
|
||
|
return HlsFD
|
||
|
elif params.get('hls_prefer_native') is True:
|
||
|
return HlsFD
|
||
|
elif params.get('hls_prefer_native') is False:
|
||
|
return FFmpegFD
|
||
9 years ago
|
|
||
4 years ago
|
return PROTOCOL_MAP.get(protocol, default)
|
||
10 years ago
|
|
||
10 years ago
|
|
||
|
__all__ = [
|
||
|
'get_suitable_downloader',
|
||
|
'FileDownloader',
|
||
|
]
|