Closed wader closed 4 months ago
So this is what's happening:
1 the extracted formats don't include any combined formats
2 the command using --load-info-json ...
asks for a combined format
3 failing to find a match causes ExtractorError
to be raised
4 the top-level method download_with_info_file()
that processes the info_json file doesn't handle that exception
5 it calls process_ie_result()
which, unlike the method extract_info()
called in the normal case, does not wrap its core processing with _handle_extraction_exceptions
.
If this is the expected behaviour, a solution is just to ask for merged formats as a fallback.
If not, what should happen? In this case there's no point raising ReExtractInfo
because the same error will happen after extracting again. However:
ExtractorError
(and does this depend on whether the error occurs with --load-info-json ...
)?Good question, not sure. My main concern is that it ends up with an uncaught exception and a stack trace and no clear "ERRROR: ..." gets printed for something that is not an internal error etc. The "ERROR: " line is what goutubedl uses to know if and what went wrong.
I think this should work:
diff --git a/yt_dlp/YoutubeDL.py b/yt_dlp/YoutubeDL.py
index ef66306b1..b6578ca01 100644
--- a/yt_dlp/YoutubeDL.py
+++ b/yt_dlp/YoutubeDL.py
@@ -3576,6 +3576,8 @@ def download_with_info_file(self, info_filename):
raise
self.report_warning(f'The info failed to download: {e}; trying with URL {webpage_url}')
self.download([webpage_url])
+ except ExtractorError as e:
+ self.report_error(e)
return self._download_retcode
@staticmethod
The bug is worse when you consider that yt-dlp supports JSON array input with multiple info dicts.
write the JSON array:
yt-dlp -j "https://www.youtube.com/playlist?list=OLAK5uy_ltT-RYqjC7ogqlxJs8SmagEbWLEf5TALo" | jq -cs > list.json
load it back and select a non-existent format without the above patch:
yt-dlp --load-info-json list.json -f nonexistent
ERROR: Do not return 'artist' when 'artists' is present; please report this issue on https://github.com/yt-dlp/yt-dlp/issues?q= , filling out the appropriate issue template. Confirm you are on the latest version using yt-dlp -U
ERROR: Do not return 'creator' when 'creators' is present; please report this issue on https://github.com/yt-dlp/yt-dlp/issues?q= , filling out the appropriate issue template. Confirm you are on the latest version using yt-dlp -U
Traceback (most recent call last):
File "/home/bashonly/bin/yt-dlp", line 14, in <module>
sys.exit(main())
^^^^^^
File "/home/bashonly/git/yt-dlp/yt_dlp/__init__.py", line 1030, in main
_exit(*variadic(_real_main(argv)))
^^^^^^^^^^^^^^^^
File "/home/bashonly/git/yt-dlp/yt_dlp/__init__.py", line 1018, in _real_main
return ydl.download_with_info_file(expand_path(opts.load_info_filename))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/bashonly/git/yt-dlp/yt_dlp/YoutubeDL.py", line 3570, in download_with_info_file
self.__download_wrapper(self.process_ie_result)(info, download=True)
File "/home/bashonly/git/yt-dlp/yt_dlp/YoutubeDL.py", line 3531, in wrapper
res = func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/home/bashonly/git/yt-dlp/yt_dlp/YoutubeDL.py", line 1808, in process_ie_result
ie_result = self.process_video_result(ie_result, download=download)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/bashonly/git/yt-dlp/yt_dlp/YoutubeDL.py", line 2928, in process_video_result
raise ExtractorError(
yt_dlp.utils.ExtractorError: [youtube] gKgB0flHIkA: Requested format is not available. Use --list-formats for a list of available formats
this results in the uncaught exception and yt-dlp exits during processing of the first info dict.
with the patch, the exception is caught and all info dicts are processed:
yt-dlp --load-info-json list.json -f nonexistent
ERROR: Do not return 'artist' when 'artists' is present; please report this issue on https://github.com/yt-dlp/yt-dlp/issues?q= , filling out the appropriate issue template. Confirm you are on the latest version using yt-dlp -U
ERROR: Do not return 'creator' when 'creators' is present; please report this issue on https://github.com/yt-dlp/yt-dlp/issues?q= , filling out the appropriate issue template. Confirm you are on the latest version using yt-dlp -U
ERROR: [youtube] gKgB0flHIkA: Requested format is not available. Use --list-formats for a list of available formats
ERROR: [youtube] y6nJVBMlZUk: Requested format is not available. Use --list-formats for a list of available formats
(EDIT: the deprecation error output is a side effect of 104a7b5a46dc1805157fb4cc11c05876934d37c1 and will be fixed by #9394)
Works great, thanks!
DO NOT REMOVE OR SKIP THE ISSUE TEMPLATE
Checklist
Provide a description that is worded well enough to be understood
When using
--load-info-json
and an extractor fails withyt_dlp.utils.ExtractorError
it seems to not catch the exception making it not print the "ERROR: " line. Using the same filter and same URL an "ERROR: " line is printed.Reproduction:
Provide verbose output that clearly demonstrates the problem
yt-dlp -vU <your command line>
)'verbose': True
toYoutubeDL
params instead[debug] Command-line config
) and insert it belowComplete Verbose Output