mirror of https://github.com/blackjack4494/yt-dlc
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.
64 lines
1.6 KiB
Python
64 lines
1.6 KiB
Python
11 years ago
|
from __future__ import unicode_literals
|
||
|
|
||
11 years ago
|
from .common import FileDownloader
|
||
10 years ago
|
from .f4m import F4mFD
|
||
11 years ago
|
from .hls import HlsFD
|
||
|
from .http import HttpFD
|
||
|
from .rtmp import RtmpFD
|
||
10 years ago
|
from .dash import DashSegmentsFD
|
||
9 years ago
|
from .rtsp import RtspFD
|
||
8 years ago
|
from .ism import IsmFD
|
||
4 years ago
|
from .youtube_live_chat import YoutubeLiveChatReplayFD
|
||
9 years ago
|
from .external import (
|
||
|
get_external_downloader,
|
||
|
FFmpegFD,
|
||
|
)
|
||
11 years ago
|
|
||
|
from ..utils import (
|
||
10 years ago
|
determine_protocol,
|
||
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
|
'youtube_live_chat_replay': YoutubeLiveChatReplayFD,
|
||
10 years ago
|
}
|
||
11 years ago
|
|
||
10 years ago
|
|
||
|
def get_suitable_downloader(info_dict, params={}):
|
||
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
|
||
|
|
||
8 years ago
|
if protocol.startswith('m3u8') and info_dict.get('is_live'):
|
||
|
return FFmpegFD
|
||
|
|
||
9 years ago
|
if protocol == 'm3u8' and params.get('hls_prefer_native') is True:
|
||
9 years ago
|
return HlsFD
|
||
10 years ago
|
|
||
9 years ago
|
if protocol == 'm3u8_native' and params.get('hls_prefer_native') is False:
|
||
|
return FFmpegFD
|
||
|
|
||
10 years ago
|
return PROTOCOL_MAP.get(protocol, HttpFD)
|
||
|
|
||
10 years ago
|
|
||
|
__all__ = [
|
||
|
'get_suitable_downloader',
|
||
|
'FileDownloader',
|
||
|
]
|