mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-09-05 02:19:36 +02:00
[YoutubeDL] Filter requested info fields on --load-info
as well
In order to properly handle JSON info files generated by youtube-dl versions prior to 4070b458ec
This commit is contained in:
parent
67fc8ecd53
commit
cb202fd286
@ -1337,11 +1337,8 @@ def process_info(self, info_dict):
|
|||||||
self.to_screen('[info] Video description metadata is already present')
|
self.to_screen('[info] Video description metadata is already present')
|
||||||
else:
|
else:
|
||||||
self.to_screen('[info] Writing video description metadata as JSON to: ' + infofn)
|
self.to_screen('[info] Writing video description metadata as JSON to: ' + infofn)
|
||||||
filtered_info_dict = dict(
|
|
||||||
(k, v) for k, v in info_dict.items()
|
|
||||||
if k not in ['requested_formats', 'requested_subtitles'])
|
|
||||||
try:
|
try:
|
||||||
write_json_file(filtered_info_dict, infofn)
|
write_json_file(self.filter_requested_info(info_dict), infofn)
|
||||||
except (OSError, IOError):
|
except (OSError, IOError):
|
||||||
self.report_error('Cannot write metadata to JSON file ' + infofn)
|
self.report_error('Cannot write metadata to JSON file ' + infofn)
|
||||||
return
|
return
|
||||||
@ -1491,7 +1488,7 @@ 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 = json.loads('\n'.join(f))
|
info = self.filter_requested_info(json.loads('\n'.join(f)))
|
||||||
try:
|
try:
|
||||||
self.process_ie_result(info, download=True)
|
self.process_ie_result(info, download=True)
|
||||||
except DownloadError:
|
except DownloadError:
|
||||||
@ -1503,6 +1500,12 @@ def download_with_info_file(self, info_filename):
|
|||||||
raise
|
raise
|
||||||
return self._download_retcode
|
return self._download_retcode
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def filter_requested_info(info_dict):
|
||||||
|
return dict(
|
||||||
|
(k, v) for k, v in info_dict.items()
|
||||||
|
if k not in ['requested_formats', 'requested_subtitles'])
|
||||||
|
|
||||||
def post_process(self, filename, ie_info):
|
def post_process(self, filename, ie_info):
|
||||||
"""Run all the postprocessors on the given file."""
|
"""Run all the postprocessors on the given file."""
|
||||||
info = dict(ie_info)
|
info = dict(ie_info)
|
||||||
|
Loading…
Reference in New Issue
Block a user