Repository: yt-dlp/yt-dlp
File: youtube_dlc/downloader/external.py (Python)

Code before:
        cmd += self._configuration_args()
        cmd += ['--', info_dict['url']]
        return cmd


class Aria2cFD(ExternalFD):
    AVAILABLE_OPT = '-v'

    def _make_cmd(self, tmpfilename, info_dict):
        cmd = [self.exe, '-c']
        # cmd += self._configuration_args([
        #    '--min-split-size', '1M', '--max-connection-per-server', '4'])
        # dn = os.path.dirname(tmpfilename)
        # if dn:
        #     cmd += ['--dir', dn]
        if 'url_list' not in info_dict:
            cmd += ['--out', tmpfilename]
        if info_dict.get('http_headers') is not None:
            for key, val in info_dict['http_headers'].items():
                cmd += ['--header', '%s: %s' % (key, val)]
        cmd += self._option('--interface', 'source_address')
        cmd += self._option('--all-proxy', 'proxy')
        cmd += self._bool_option('--check-certificate', 'nocheckcertificate', 'false', 'true', '=')
        cmd += self._bool_option('--remote-time', 'updatetime', 'true', 'false', '=')
        if 'url_list' in info_dict:
            cmd += self._configuration_args(['--file-allocation', 'none', '--download-result', 'hide', '--uri-selector', 'inorder', '--console-log-level', 'warn', '-x16', '-j16', '-s16'])

            url_list_file = '%s_urls.txt' % tmpfilename

            url_list = []
            for [i, url] in enumerate(info_dict['url_list']):
                tmpsegmentname = '%s_%s.fragment' % (tmpfilename, i)
                url_list.append('%s\n\tout=%s' % (url, tmpsegmentname))

            with open(url_list_file, 'w') as f:
                f.write('\n'.join(url_list))
            cmd += ['-i', url_list_file]
        else:
            cmd += ['--', info_dict['url']]
        return cmd

    def _call_downloader(self, tmpfilename, info_dict):
        """ Either overwrite this or implement _make_cmd """
        tn = os.path.basename(tmpfilename)

        file_list = []
        if 'url_list' in info_dict:
            for [i, url] in enumerate(info_dict['url_list']):
                tmpsegmentname = '%s_%s.fragment' % (tn, i)
                file_list.append(tmpsegmentname)
            info_dict['file_list'] = file_list

Review comment (suggestion):
Note that if user provides `--external-downloader-args`, these will be overwritten with them. So ensure that these are all non-essential options. You might want to move `--download-result` and `--uri-selector` elsewhere

Code after:

        # curl writes the progress to stderr so don't capture it.
        p = subprocess.Popen(cmd)
        process_communicate_or_kill(p)
        return p.returncode


class AxelFD(ExternalFD):
    AVAILABLE_OPT = '-V'

    def _make_cmd(self, tmpfilename, info_dict):
        cmd = [self.exe, '-o', tmpfilename]
        if info_dict.get('http_headers') is not None:
            for key, val in info_dict['http_headers'].items():
                cmd += ['-H', '%s: %s' % (key, val)]
        cmd += self._configuration_args()
        cmd += ['--', info_dict['url']]
        return cmd


class WgetFD(ExternalFD):
    AVAILABLE_OPT = '--version'

    def _make_cmd(self, tmpfilename, info_dict):
        cmd = [self.exe, '-O', tmpfilename, '-nv', '--no-cookies']
        if info_dict.get('http_headers') is not None:
            for key, val in info_dict['http_headers'].items():
                cmd += ['--header', '%s: %s' % (key, val)]
        cmd += self._option('--limit-rate', 'ratelimit')
        retry = self._option('--tries', 'retries')
        if len(retry) == 2:
            if retry[1] in ('inf', 'infinite'):
                retry[1] = '0'
            cmd += retry
        cmd += self._option('--bind-address', 'source_address')
        cmd += self._option('--proxy', 'proxy')
        cmd += self._valueless_option('--no-check-certificate', 'nocheckcertificate')
        cmd += self._configuration_args()
        cmd += ['--', info_dict['url']]
        return cmd


class Aria2cFD(ExternalFD):
    AVAILABLE_OPT = '-v'
    SUPPORTED_PROTOCOLS = ('http', 'https', 'ftp', 'ftps', 'frag_urls')

    def _make_cmd(self, tmpfilename, info_dict):
        cmd = [self.exe, '-c']
        dn = os.path.dirname(tmpfilename)
        if 'url_list' not in info_dict:
            cmd += ['--out', os.path.basename(tmpfilename)]