From 0b382a7d72e647681e6022e01d953af4e4b7758f Mon Sep 17 00:00:00 2001 From: tcely Date: Sun, 1 Dec 2024 17:32:05 -0500 Subject: [PATCH 1/5] Remove continue from aria2c This doesn't actually work, or make sense, without configuring the stream selector to use `inorder` instead of `default` for the algorithm. Ideally, `aria2c` would write the needed information for resuming downloads in its own file before exiting. Otherwise, it's more reliable to download everything again. --- yt_dlp/downloader/external.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yt_dlp/downloader/external.py b/yt_dlp/downloader/external.py index 7f6b5b45c..873df6c1d 100644 --- a/yt_dlp/downloader/external.py +++ b/yt_dlp/downloader/external.py @@ -293,7 +293,7 @@ def _call_downloader(self, tmpfilename, info_dict): return super()._call_downloader(tmpfilename, info_dict) def _make_cmd(self, tmpfilename, info_dict): - cmd = [self.exe, '-c', '--no-conf', + cmd = [self.exe, '--no-conf', '--console-log-level=warn', '--summary-interval=0', '--download-result=hide', '--http-accept-gzip=true', '--file-allocation=none', '-x16', '-j16', '-s16'] if 'fragments' in info_dict: From 208ab98aa7f0c5a31ecd03704015ae883f5fc2d9 Mon Sep 17 00:00:00 2001 From: tcely Date: Sun, 1 Dec 2024 19:07:19 -0500 Subject: [PATCH 2/5] aria2c should overwrite the output when resuming fails Moved renaming and overwrite arguments up with the rest. Both cases need these arguments. Save the control file every 10 seconds. Resume using the control file, or overwrite if not possible. Remove the control file when the download is completed. Print to stderr instead, just as curl does. --- yt_dlp/downloader/external.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/yt_dlp/downloader/external.py b/yt_dlp/downloader/external.py index 873df6c1d..3813c0b12 100644 --- a/yt_dlp/downloader/external.py +++ b/yt_dlp/downloader/external.py @@ -269,6 +269,7 @@ def _make_cmd(self, tmpfilename, info_dict): class Aria2cFD(ExternalFD): AVAILABLE_OPT = '-v' SUPPORTED_PROTOCOLS = ('http', 'https', 'ftp', 'ftps', 'dash_frag_urls', 'm3u8_frag_urls') + _CAPTURE_STDERR = False @staticmethod def supports_manifest(manifest): @@ -293,11 +294,13 @@ def _call_downloader(self, tmpfilename, info_dict): return super()._call_downloader(tmpfilename, info_dict) def _make_cmd(self, tmpfilename, info_dict): - cmd = [self.exe, '--no-conf', + cmd = [self.exe, '--no-conf', '--stderr=true', + '--auto-save-interval=10', '--allow-overwrite=true', '--always-resume=false', + '--auto-file-renaming=false', '--force-save=false', '--console-log-level=warn', '--summary-interval=0', '--download-result=hide', '--http-accept-gzip=true', '--file-allocation=none', '-x16', '-j16', '-s16'] if 'fragments' in info_dict: - cmd += ['--allow-overwrite=true', '--allow-piece-length-change=true'] + cmd += ['--allow-piece-length-change=true'] else: cmd += ['--min-split-size', '1M'] @@ -331,7 +334,6 @@ def _make_cmd(self, tmpfilename, info_dict): cmd += ['--dir', self._aria2c_filename(dn) + os.path.sep] if 'fragments' not in info_dict: cmd += ['--out', self._aria2c_filename(os.path.basename(tmpfilename))] - cmd += ['--auto-file-renaming=false'] if 'fragments' in info_dict: cmd += ['--uri-selector=inorder'] From 087cb24bb2101c3dcb08b394df28b734b940eb8f Mon Sep 17 00:00:00 2001 From: tcely Date: Sun, 8 Dec 2024 01:36:52 -0500 Subject: [PATCH 3/5] Honor continuedl with aria2c --remove-control-file[=true|false] Remove control file before download. Using with --allow-overwrite=true, download always starts from scratch. --- yt_dlp/downloader/external.py | 1 + 1 file changed, 1 insertion(+) diff --git a/yt_dlp/downloader/external.py b/yt_dlp/downloader/external.py index 3813c0b12..766dd7b33 100644 --- a/yt_dlp/downloader/external.py +++ b/yt_dlp/downloader/external.py @@ -315,6 +315,7 @@ def _make_cmd(self, tmpfilename, info_dict): cmd += self._bool_option('--check-certificate', 'nocheckcertificate', 'false', 'true', '=') cmd += self._bool_option('--remote-time', 'updatetime', 'true', 'false', '=') cmd += self._bool_option('--show-console-readout', 'noprogress', 'false', 'true', '=') + cmd += self._bool_option('--remove-control-file', 'continuedl', 'false', 'true', '=') cmd += self._configuration_args() if '__rpc' in info_dict: From 670da95bac8b6e5555446a8678f9bcf5e4ce3d97 Mon Sep 17 00:00:00 2001 From: tcely Date: Wed, 25 Dec 2024 03:24:07 -0500 Subject: [PATCH 4/5] Move required flags below _configuration_args() - Resume or overwrite the specified file - Do not rename output to a non-existent file - Do not abort the transfer when resume fails - Do not preserve the control file after transfers complete --- yt_dlp/downloader/external.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/yt_dlp/downloader/external.py b/yt_dlp/downloader/external.py index 766dd7b33..257c03367 100644 --- a/yt_dlp/downloader/external.py +++ b/yt_dlp/downloader/external.py @@ -294,9 +294,7 @@ def _call_downloader(self, tmpfilename, info_dict): return super()._call_downloader(tmpfilename, info_dict) def _make_cmd(self, tmpfilename, info_dict): - cmd = [self.exe, '--no-conf', '--stderr=true', - '--auto-save-interval=10', '--allow-overwrite=true', '--always-resume=false', - '--auto-file-renaming=false', '--force-save=false', + cmd = [self.exe, '--no-conf', '--stderr=true', '--auto-save-interval=10', '--console-log-level=warn', '--summary-interval=0', '--download-result=hide', '--http-accept-gzip=true', '--file-allocation=none', '-x16', '-j16', '-s16'] if 'fragments' in info_dict: @@ -317,6 +315,11 @@ def _make_cmd(self, tmpfilename, info_dict): cmd += self._bool_option('--show-console-readout', 'noprogress', 'false', 'true', '=') cmd += self._bool_option('--remove-control-file', 'continuedl', 'false', 'true', '=') cmd += self._configuration_args() + # do not allow changing these flags + cmd += ['--allow-overwrite=true'] + cmd += ['--always-resume=false'] + cmd += ['--auto-file-renaming=false'] + cmd += ['--force-save=false'] if '__rpc' in info_dict: cmd += [ From 565999e58ae1c01ef3ac5040725f2f324d22ac8f Mon Sep 17 00:00:00 2001 From: tcely Date: Wed, 25 Dec 2024 03:29:35 -0500 Subject: [PATCH 5/5] Remove stderr changes --- yt_dlp/downloader/external.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/yt_dlp/downloader/external.py b/yt_dlp/downloader/external.py index 257c03367..d7cd8f38e 100644 --- a/yt_dlp/downloader/external.py +++ b/yt_dlp/downloader/external.py @@ -269,7 +269,6 @@ def _make_cmd(self, tmpfilename, info_dict): class Aria2cFD(ExternalFD): AVAILABLE_OPT = '-v' SUPPORTED_PROTOCOLS = ('http', 'https', 'ftp', 'ftps', 'dash_frag_urls', 'm3u8_frag_urls') - _CAPTURE_STDERR = False @staticmethod def supports_manifest(manifest): @@ -294,7 +293,7 @@ def _call_downloader(self, tmpfilename, info_dict): return super()._call_downloader(tmpfilename, info_dict) def _make_cmd(self, tmpfilename, info_dict): - cmd = [self.exe, '--no-conf', '--stderr=true', '--auto-save-interval=10', + cmd = [self.exe, '--no-conf', '--auto-save-interval=10', '--console-log-level=warn', '--summary-interval=0', '--download-result=hide', '--http-accept-gzip=true', '--file-allocation=none', '-x16', '-j16', '-s16'] if 'fragments' in info_dict: