1
0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2024-11-02 01:02:48 +01:00

Recursively remove private keys from infojson

Related: https://github.com/yt-dlp/yt-dlp/issues/42
This commit is contained in:
pukkandan 2021-03-18 20:55:16 +05:30
parent dcf64d43e0
commit 5226731e2d
No known key found for this signature in database
GPG Key ID: 0F00D95A001F4698

View File

@ -1199,7 +1199,6 @@ def __process_playlist(self, ie_result, download):
else: else:
playlist_info = dict(ie_result) playlist_info = dict(ie_result)
# playlist_info['entries'] = list(playlist_info['entries']) # Entries is a generator which shouldnot be resolved here # playlist_info['entries'] = list(playlist_info['entries']) # Entries is a generator which shouldnot be resolved here
del playlist_info['entries']
self.to_screen('[info] Writing playlist metadata as JSON to: ' + infofn) self.to_screen('[info] Writing playlist metadata as JSON to: ' + infofn)
try: try:
write_json_file(self.filter_requested_info(playlist_info), infofn) write_json_file(self.filter_requested_info(playlist_info), infofn)
@ -2528,10 +2527,16 @@ def download_with_info_file(self, info_filename):
@staticmethod @staticmethod
def filter_requested_info(info_dict): def filter_requested_info(info_dict):
fields_to_remove = ('requested_formats', 'requested_subtitles') exceptions = {
return dict( 'remove': ['requested_formats', 'requested_subtitles', 'filepath', 'entries'],
(k, v) for k, v in info_dict.items() 'keep': ['_type'],
if (k[0] != '_' or k == '_type') and k not in fields_to_remove) }
keep_key = lambda k: k in exceptions['keep'] or not (k.startswith('_') or k in exceptions['remove'])
filter_fn = lambda obj: (
list(map(filter_fn, obj)) if isinstance(obj, (list, tuple))
else obj if not isinstance(obj, dict)
else dict((k, filter_fn(v)) for k, v in obj.items() if keep_key(k)))
return filter_fn(info_dict)
def run_pp(self, pp, infodict): def run_pp(self, pp, infodict):
files_to_delete = [] files_to_delete = []