]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/downloader/__init__.py
Imported Upstream version 2015.07.21
[youtubedl] / youtube_dl / downloader / __init__.py
1 from __future__ import unicode_literals
2
3 from .common import FileDownloader
4 from .external import get_external_downloader
5 from .f4m import F4mFD
6 from .hls import HlsFD
7 from .hls import NativeHlsFD
8 from .http import HttpFD
9 from .rtsp import RtspFD
10 from .rtmp import RtmpFD
11 from .dash import DashSegmentsFD
12
13 from ..utils import (
14 determine_protocol,
15 )
16
17 PROTOCOL_MAP = {
18 'rtmp': RtmpFD,
19 'm3u8_native': NativeHlsFD,
20 'm3u8': HlsFD,
21 'mms': RtspFD,
22 'rtsp': RtspFD,
23 'f4m': F4mFD,
24 'http_dash_segments': DashSegmentsFD,
25 }
26
27
28 def get_suitable_downloader(info_dict, params={}):
29 """Get the downloader class that can handle the info dict."""
30 protocol = determine_protocol(info_dict)
31 info_dict['protocol'] = protocol
32
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
39 if protocol == 'm3u8' and params.get('hls_prefer_native'):
40 return NativeHlsFD
41
42 return PROTOCOL_MAP.get(protocol, HttpFD)
43
44
45 __all__ = [
46 'get_suitable_downloader',
47 'FileDownloader',
48 ]