aboutsummaryrefslogtreecommitdiffstats
path: root/youtube_dl/downloader/__init__.py
diff options
context:
space:
mode:
authorJames Taylor <user234683@users.noreply.github.com>2018-07-11 01:31:44 -0700
committerJames Taylor <user234683@users.noreply.github.com>2018-07-11 01:31:44 -0700
commitaea11c407f7be904037183da152c4cdf561cd65e (patch)
tree5fad52326feee68c3771becee44fdf24ceebca05 /youtube_dl/downloader/__init__.py
parent2b308ec9f0fd1ba296db7bcdcea9f93aebf6eaa1 (diff)
downloadyt-local-aea11c407f7be904037183da152c4cdf561cd65e.tar.lz
yt-local-aea11c407f7be904037183da152c4cdf561cd65e.tar.xz
yt-local-aea11c407f7be904037183da152c4cdf561cd65e.zip
track custom youtube-dl distribution
Diffstat (limited to 'youtube_dl/downloader/__init__.py')
-rw-r--r--youtube_dl/downloader/__init__.py61
1 files changed, 61 insertions, 0 deletions
diff --git a/youtube_dl/downloader/__init__.py b/youtube_dl/downloader/__init__.py
new file mode 100644
index 0000000..2e485df
--- /dev/null
+++ b/youtube_dl/downloader/__init__.py
@@ -0,0 +1,61 @@
+from __future__ import unicode_literals
+
+from .common import FileDownloader
+from .f4m import F4mFD
+from .hls import HlsFD
+from .http import HttpFD
+from .rtmp import RtmpFD
+from .dash import DashSegmentsFD
+from .rtsp import RtspFD
+from .ism import IsmFD
+from .external import (
+ get_external_downloader,
+ FFmpegFD,
+)
+
+from ..utils import (
+ determine_protocol,
+)
+
+PROTOCOL_MAP = {
+ 'rtmp': RtmpFD,
+ 'm3u8_native': HlsFD,
+ 'm3u8': FFmpegFD,
+ 'mms': RtspFD,
+ 'rtsp': RtspFD,
+ 'f4m': F4mFD,
+ 'http_dash_segments': DashSegmentsFD,
+ 'ism': IsmFD,
+}
+
+
+def get_suitable_downloader(info_dict, params={}):
+ """Get the downloader class that can handle the info dict."""
+ protocol = determine_protocol(info_dict)
+ info_dict['protocol'] = protocol
+
+ # 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):
+ # return FFmpegFD
+
+ external_downloader = params.get('external_downloader')
+ if external_downloader is not None:
+ ed = get_external_downloader(external_downloader)
+ if ed.can_download(info_dict):
+ return ed
+
+ if protocol.startswith('m3u8') and info_dict.get('is_live'):
+ return FFmpegFD
+
+ if protocol == 'm3u8' and params.get('hls_prefer_native') is True:
+ return HlsFD
+
+ if protocol == 'm3u8_native' and params.get('hls_prefer_native') is False:
+ return FFmpegFD
+
+ return PROTOCOL_MAP.get(protocol, HttpFD)
+
+
+__all__ = [
+ 'get_suitable_downloader',
+ 'FileDownloader',
+]