]> jfr.im git - yt-dlp.git/blob - youtube_dl/downloader/__init__.py
[skip travis] adding automerge support
[yt-dlp.git] / youtube_dl / downloader / __init__.py
1 from __future__ import unicode_literals
2
3 from .common import FileDownloader
4 from .f4m import F4mFD
5 from .hls import HlsFD
6 from .http import HttpFD
7 from .rtmp import RtmpFD
8 from .dash import DashSegmentsFD
9 from .rtsp import RtspFD
10 from .ism import IsmFD
11 from .youtube_live_chat import YoutubeLiveChatReplayFD
12 from .external import (
13 get_external_downloader,
14 FFmpegFD,
15 )
16
17 from ..utils import (
18 determine_protocol,
19 )
20
21 PROTOCOL_MAP = {
22 'rtmp': RtmpFD,
23 'm3u8_native': HlsFD,
24 'm3u8': FFmpegFD,
25 'mms': RtspFD,
26 'rtsp': RtspFD,
27 'f4m': F4mFD,
28 'http_dash_segments': DashSegmentsFD,
29 'ism': IsmFD,
30 'youtube_live_chat_replay': YoutubeLiveChatReplayFD,
31 }
32
33
34 def get_suitable_downloader(info_dict, params={}):
35 """Get the downloader class that can handle the info dict."""
36 protocol = determine_protocol(info_dict)
37 info_dict['protocol'] = protocol
38
39 # 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):
40 # return FFmpegFD
41
42 external_downloader = params.get('external_downloader')
43 if external_downloader is not None:
44 ed = get_external_downloader(external_downloader)
45 if ed.can_download(info_dict):
46 return ed
47
48 if protocol.startswith('m3u8') and info_dict.get('is_live'):
49 return FFmpegFD
50
51 if protocol == 'm3u8' and params.get('hls_prefer_native') is True:
52 return HlsFD
53
54 if protocol == 'm3u8_native' and params.get('hls_prefer_native') is False:
55 return FFmpegFD
56
57 return PROTOCOL_MAP.get(protocol, HttpFD)
58
59
60 __all__ = [
61 'get_suitable_downloader',
62 'FileDownloader',
63 ]