__init__.py 672 B

1234567891011121314151617181920212223242526
  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 ..utils import (
  8. determine_ext,
  9. )
  10. def get_suitable_downloader(info_dict):
  11. """Get the downloader class that can handle the info dict."""
  12. url = info_dict['url']
  13. protocol = info_dict.get('protocol')
  14. if url.startswith('rtmp'):
  15. return RtmpFD
  16. if (protocol == 'm3u8') or (protocol is None and determine_ext(url) == 'm3u8'):
  17. return HlsFD
  18. if url.startswith('mms') or url.startswith('rtsp'):
  19. return MplayerFD
  20. else:
  21. return HttpFD