]>
Commit | Line | Data |
---|---|---|
db1f3888 PH |
1 | from __future__ import unicode_literals |
2 | ||
3bc2ddcc | 3 | from .common import FileDownloader |
222516d9 | 4 | from .f4m import F4mFD |
3bc2ddcc JMF |
5 | from .hls import HlsFD |
6 | from .http import HttpFD | |
3bc2ddcc | 7 | from .rtmp import RtmpFD |
b9258c61 | 8 | from .dash import DashSegmentsFD |
be24916a | 9 | from .rtsp import RtspFD |
12b84ac8 | 10 | from .external import ( |
11 | get_external_downloader, | |
12 | FFmpegFD, | |
13 | ) | |
3bc2ddcc JMF |
14 | |
15 | from ..utils import ( | |
a055469f | 16 | determine_protocol, |
3bc2ddcc JMF |
17 | ) |
18 | ||
a055469f PH |
19 | PROTOCOL_MAP = { |
20 | 'rtmp': RtmpFD, | |
12b84ac8 | 21 | 'm3u8_native': HlsFD, |
22 | 'm3u8': FFmpegFD, | |
be24916a | 23 | 'mms': RtspFD, |
24 | 'rtsp': RtspFD, | |
a055469f | 25 | 'f4m': F4mFD, |
423d2be5 | 26 | 'http_dash_segments': DashSegmentsFD, |
a055469f | 27 | } |
f89197d7 | 28 | |
a055469f PH |
29 | |
30 | def get_suitable_downloader(info_dict, params={}): | |
3bc2ddcc | 31 | """Get the downloader class that can handle the info dict.""" |
a055469f PH |
32 | protocol = determine_protocol(info_dict) |
33 | info_dict['protocol'] = protocol | |
34 | ||
6ae27bed | 35 | # 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): |
da1973a0 | 36 | # return FFmpegFD |
12b84ac8 | 37 | |
222516d9 PH |
38 | external_downloader = params.get('external_downloader') |
39 | if external_downloader is not None: | |
40 | ed = get_external_downloader(external_downloader) | |
2cb99ebb | 41 | if ed.can_download(info_dict): |
222516d9 PH |
42 | return ed |
43 | ||
85729c51 | 44 | if protocol == 'm3u8' and params.get('hls_prefer_native'): |
12b84ac8 | 45 | return HlsFD |
85729c51 | 46 | |
a055469f PH |
47 | return PROTOCOL_MAP.get(protocol, HttpFD) |
48 | ||
14d4e90e PH |
49 | |
50 | __all__ = [ | |
51 | 'get_suitable_downloader', | |
52 | 'FileDownloader', | |
53 | ] |