diff options
author | Jaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com> | 2013-09-23 17:59:27 +0200 |
---|---|---|
committer | Jaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com> | 2013-12-11 16:18:48 +0100 |
commit | 3bc2ddccc8622379ec11e802dff30a635285a9c8 (patch) | |
tree | 63fe2e72f439c5db7f8047f395eca030981e620b /youtube_dl/downloader/__init__.py | |
parent | 8ab470f1b26b6c42ab74ceb345994c201743bed8 (diff) |
Move FileDownloader to its own module and create a new class for each download process
A suitable downloader can be found using the 'get_suitable_downloader' function.
Each subclass implements 'real_download', for downloading an info dict you call the 'download' method, which first checks if the video has already been downloaded
Diffstat (limited to 'youtube_dl/downloader/__init__.py')
-rw-r--r-- | youtube_dl/downloader/__init__.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/youtube_dl/downloader/__init__.py b/youtube_dl/downloader/__init__.py new file mode 100644 index 000000000..f19b490f1 --- /dev/null +++ b/youtube_dl/downloader/__init__.py @@ -0,0 +1,23 @@ +from .common import FileDownloader +from .hls import HlsFD +from .http import HttpFD +from .mplayer import MplayerFD +from .rtmp import RtmpFD + +from ..utils import ( + determine_ext, +) + +def get_suitable_downloader(info_dict): + """Get the downloader class that can handle the info dict.""" + url = info_dict['url'] + + if url.startswith('rtmp'): + return RtmpFD + if determine_ext(url) == u'm3u8': + return HlsFD + if url.startswith('mms') or url.startswith('rtsp'): + return MplayerFD + else: + return HttpFD + |