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

Code before:
        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

        cmd = [encodeArgument(a) for a in self._make_cmd(tmpfilename, info_dict)]

Review comment (suggestion):
It's not good to use `.txt` extension. Is there any standard extension for these types of files? If not we can use something like `.frag.urls`

Code after:
        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)]
        verbose_level_args = ['--console-log-level=warn', '--summary-interval=0']
        cmd += self._configuration_args(['--file-allocation=none', '-x16', '-j16', '-s16'] + verbose_level_args)