You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
910 B

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