[downloader] Improve downloader selection
[youtube-dl] / youtube_dl / downloader / __init__.py
1 from __future__ import unicode_literals
2
3 from .common import FileDownloader
4 from .hls import HlsFD
5 from .hls import NativeHlsFD
6 from .http import HttpFD
7 from .mplayer import MplayerFD
8 from .rtmp import RtmpFD
9 from .f4m import F4mFD
10
11 from ..utils import (
12     determine_protocol,
13 )
14
15 PROTOCOL_MAP = {
16     'rtmp': RtmpFD,
17     'm3u8_native': NativeHlsFD,
18     'm3u8': HlsFD,
19     'mms': MplayerFD,
20     'rtsp': MplayerFD,
21     'f4m': F4mFD,
22 }
23
24
25 def get_suitable_downloader(info_dict, params={}):
26     """Get the downloader class that can handle the info dict."""
27     protocol = determine_protocol(info_dict)
28     info_dict['protocol'] = protocol
29
30     return PROTOCOL_MAP.get(protocol, HttpFD)
31
32
33 __all__ = [
34     'get_suitable_downloader',
35     'FileDownloader',
36 ]