mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-19 14:49:15 +00:00
Support loading info.json with a list at it's root
This commit is contained in:
parent
96f5d29db0
commit
34d3df72e9
|
@ -3380,18 +3380,19 @@ def download_with_info_file(self, info_filename):
|
||||||
[info_filename], mode='r',
|
[info_filename], mode='r',
|
||||||
openhook=fileinput.hook_encoded('utf-8'))) as f:
|
openhook=fileinput.hook_encoded('utf-8'))) as f:
|
||||||
# FileInput doesn't have a read method, we can't call json.load
|
# FileInput doesn't have a read method, we can't call json.load
|
||||||
info = self.sanitize_info(json.loads('\n'.join(f)), self.params.get('clean_infojson', True))
|
infos = [self.sanitize_info(info, self.params.get('clean_infojson', True))
|
||||||
try:
|
for info in variadic(json.loads('\n'.join(f)))]
|
||||||
self.__download_wrapper(self.process_ie_result)(info, download=True)
|
for info in infos:
|
||||||
except (DownloadError, EntryNotInPlaylist, ReExtractInfo) as e:
|
try:
|
||||||
if not isinstance(e, EntryNotInPlaylist):
|
self.__download_wrapper(self.process_ie_result)(info, download=True)
|
||||||
self.to_stderr('\r')
|
except (DownloadError, EntryNotInPlaylist, ReExtractInfo) as e:
|
||||||
webpage_url = info.get('webpage_url')
|
if not isinstance(e, EntryNotInPlaylist):
|
||||||
if webpage_url is not None:
|
self.to_stderr('\r')
|
||||||
|
webpage_url = info.get('webpage_url')
|
||||||
|
if webpage_url is None:
|
||||||
|
raise
|
||||||
self.report_warning(f'The info failed to download: {e}; trying with URL {webpage_url}')
|
self.report_warning(f'The info failed to download: {e}; trying with URL {webpage_url}')
|
||||||
return self.download([webpage_url])
|
self.download([webpage_url])
|
||||||
else:
|
|
||||||
raise
|
|
||||||
return self._download_retcode
|
return self._download_retcode
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
|
@ -966,6 +966,8 @@ def _real_main(argv=None):
|
||||||
parser.destroy()
|
parser.destroy()
|
||||||
try:
|
try:
|
||||||
if opts.load_info_filename is not None:
|
if opts.load_info_filename is not None:
|
||||||
|
if all_urls:
|
||||||
|
ydl.report_warning('URLs are ignored due to --load-info-json')
|
||||||
return ydl.download_with_info_file(expand_path(opts.load_info_filename))
|
return ydl.download_with_info_file(expand_path(opts.load_info_filename))
|
||||||
else:
|
else:
|
||||||
return ydl.download(all_urls)
|
return ydl.download(all_urls)
|
||||||
|
|
Loading…
Reference in a new issue