]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/downloader/__init__.py
Merge tag 'upstream/2016.08.17'
[youtubedl] / 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 .external import (
11 get_external_downloader,
12 FFmpegFD,
13 )
14
15 from ..utils import (
16 determine_protocol,
17 )
18
19 PROTOCOL_MAP = {
20 'rtmp': RtmpFD,
21 'm3u8_native': HlsFD,
22 'm3u8': FFmpegFD,
23 'mms': RtspFD,
24 'rtsp': RtspFD,
25 'f4m': F4mFD,
26 'http_dash_segments': DashSegmentsFD,
27 }
28
29
30 def get_suitable_downloader(info_dict, params={}):
31 """Get the downloader class that can handle the info dict."""
32 protocol = determine_protocol(info_dict)
33 info_dict['protocol'] = protocol
34
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):
36 # return FFmpegFD
37
38 external_downloader = params.get('external_downloader')
39 if external_downloader is not None:
40 ed = get_external_downloader(external_downloader)
41 if ed.can_download(info_dict):
42 return ed
43
44 if protocol == 'm3u8' and params.get('hls_prefer_native') is True:
45 return HlsFD
46
47 if protocol == 'm3u8_native' and params.get('hls_prefer_native') is False:
48 return FFmpegFD
49
50 return PROTOCOL_MAP.get(protocol, HttpFD)
51
52
53 __all__ = [
54 'get_suitable_downloader',
55 'FileDownloader',
56 ]