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