]>
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 |
b2758123 | 10 | from .ism import IsmFD |
12b84ac8 | 11 | from .external import ( |
12 | get_external_downloader, | |
13 | FFmpegFD, | |
14 | ) | |
3bc2ddcc JMF |
15 | |
16 | from ..utils import ( | |
a055469f | 17 | determine_protocol, |
3bc2ddcc JMF |
18 | ) |
19 | ||
a055469f PH |
20 | PROTOCOL_MAP = { |
21 | 'rtmp': RtmpFD, | |
12b84ac8 | 22 | 'm3u8_native': HlsFD, |
23 | 'm3u8': FFmpegFD, | |
be24916a | 24 | 'mms': RtspFD, |
25 | 'rtsp': RtspFD, | |
a055469f | 26 | 'f4m': F4mFD, |
423d2be5 | 27 | 'http_dash_segments': DashSegmentsFD, |
b2758123 | 28 | 'ism': IsmFD, |
a055469f | 29 | } |
f89197d7 | 30 | |
a055469f PH |
31 | |
32 | def get_suitable_downloader(info_dict, params={}): | |
3bc2ddcc | 33 | """Get the downloader class that can handle the info dict.""" |
a055469f PH |
34 | protocol = determine_protocol(info_dict) |
35 | info_dict['protocol'] = protocol | |
36 | ||
6ae27bed | 37 | # 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 | 38 | # return FFmpegFD |
12b84ac8 | 39 | |
222516d9 PH |
40 | external_downloader = params.get('external_downloader') |
41 | if external_downloader is not None: | |
42 | ed = get_external_downloader(external_downloader) | |
2cb99ebb | 43 | if ed.can_download(info_dict): |
222516d9 PH |
44 | return ed |
45 | ||
2bfaf89b RA |
46 | if protocol.startswith('m3u8') and info_dict.get('is_live'): |
47 | return FFmpegFD | |
48 | ||
bf09af3a | 49 | if protocol == 'm3u8' and params.get('hls_prefer_native') is True: |
12b84ac8 | 50 | return HlsFD |
85729c51 | 51 | |
bf09af3a S |
52 | if protocol == 'm3u8_native' and params.get('hls_prefer_native') is False: |
53 | return FFmpegFD | |
54 | ||
a055469f PH |
55 | return PROTOCOL_MAP.get(protocol, HttpFD) |
56 | ||
14d4e90e PH |
57 | |
58 | __all__ = [ | |
59 | 'get_suitable_downloader', | |
60 | 'FileDownloader', | |
61 | ] |