diff options
author | Philipp Hagemeister <phihag@phihag.de> | 2015-01-24 13:33:45 +0100 |
---|---|---|
committer | Philipp Hagemeister <phihag@phihag.de> | 2015-01-24 13:33:45 +0100 |
commit | 384b62028a4c3c35727d714ccfc9944a36934069 (patch) | |
tree | 76006b906a04a54e0d076e1feb47188f64c281f3 /youtube_dl | |
parent | b95aab8482881e8b1f7fba856da816a2dbc50d0f (diff) |
[downloader/external] Add curl and aria2c (Closes #182)
Diffstat (limited to 'youtube_dl')
-rw-r--r-- | youtube_dl/downloader/external.py | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/youtube_dl/downloader/external.py b/youtube_dl/downloader/external.py index c05596255..7ebe40096 100644 --- a/youtube_dl/downloader/external.py +++ b/youtube_dl/downloader/external.py @@ -97,13 +97,22 @@ class ExternalFD(FileDownloader): self._debug_cmd(cmd, subprocess_encoding) p = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - stdout, stderr = p.communicate() + cmd, stderr=subprocess.PIPE) + _, stderr = p.communicate() if p.returncode != 0: self.to_stderr(stderr) return p.returncode +class CurlFD(ExternalFD): + def _make_cmd(self, tmpfilename, info_dict): + cmd = [self.exe, '-o', tmpfilename] + for key, val in self._calc_headers(info_dict).items(): + cmd += ['--header', '%s: %s' % (key, val)] + cmd += ['--', info_dict['url']] + return cmd + + class WgetFD(ExternalFD): def _make_cmd(self, tmpfilename, info_dict): cmd = [self.exe, '-O', tmpfilename, '-nv', '--no-cookies'] @@ -113,6 +122,20 @@ class WgetFD(ExternalFD): return cmd +class Aria2cFD(ExternalFD): + def _make_cmd(self, tmpfilename, info_dict): + cmd = [ + self.exe, '-c', + '--min-split-size', '1M', '--max-connection-per-server', '4'] + dn = os.path.dirname(tmpfilename) + if dn: + cmd += ['--dir', dn] + cmd += ['--out', os.path.basename(tmpfilename)] + for key, val in self._calc_headers(info_dict).items(): + cmd += ['--header', '%s: %s' % (key, val)] + cmd += ['--', info_dict['url']] + return cmd + _BY_NAME = dict( (klass.get_basename(), klass) for name, klass in globals().items() |