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