29 lines
752 B

  1. from __future__ import unicode_literals
  2. from .common import FileDownloader
  3. from .hls import HlsFD
  4. from .http import HttpFD
  5. from .mplayer import MplayerFD
  6. from .rtmp import RtmpFD
  7. from .f4m import F4mFD
  8. from ..utils import (
  9. determine_ext,
  10. )
  11. def get_suitable_downloader(info_dict):
  12. """Get the downloader class that can handle the info dict."""
  13. url = info_dict['url']
  14. protocol = info_dict.get('protocol')
  15. if url.startswith('rtmp'):
  16. return RtmpFD
  17. if (protocol == 'm3u8') or (protocol is None and determine_ext(url) == 'm3u8'):
  18. return HlsFD
  19. if url.startswith('mms') or url.startswith('rtsp'):
  20. return MplayerFD
  21. if determine_ext(url) == 'f4m':
  22. return F4mFD
  23. else:
  24. return HttpFD