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.

53 lines
1.3 KiB

  1. from __future__ import unicode_literals
  2. from .common import FileDownloader
  3. from .f4m import F4mFD
  4. from .hls import HlsFD
  5. from .http import HttpFD
  6. from .rtmp import RtmpFD
  7. from .dash import DashSegmentsFD
  8. from .rtsp import RtspFD
  9. from .external import (
  10. get_external_downloader,
  11. FFmpegFD,
  12. )
  13. from ..utils import (
  14. determine_protocol,
  15. )
  16. PROTOCOL_MAP = {
  17. 'rtmp': RtmpFD,
  18. 'm3u8_native': HlsFD,
  19. 'm3u8': FFmpegFD,
  20. 'mms': RtspFD,
  21. 'rtsp': RtspFD,
  22. 'f4m': F4mFD,
  23. 'http_dash_segments': DashSegmentsFD,
  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. # if (info_dict.get('start_time') or info_dict.get('end_time')) and not info_dict.get('requested_formats') and FFmpegFD.can_download(info_dict):
  30. # return FFmpegFD
  31. external_downloader = params.get('external_downloader')
  32. if external_downloader is not None:
  33. ed = get_external_downloader(external_downloader)
  34. if ed.can_download(info_dict):
  35. return ed
  36. if protocol == 'm3u8' and params.get('hls_prefer_native'):
  37. return HlsFD
  38. return PROTOCOL_MAP.get(protocol, HttpFD)
  39. __all__ = [
  40. 'get_suitable_downloader',
  41. 'FileDownloader',
  42. ]