1
0
mirror of https://github.com/ytdl-org/youtube-dl.git synced 2025-06-22 11:26:20 +00:00

Merge 86808ab7c5c520541fac187bc15a3092a09b1aa0 into c052a16f72af7dd7671d4dd62826de71cd99dfb6

This commit is contained in:
Knight Hat 2025-04-14 08:38:28 +00:00 committed by GitHub
commit eca73242b8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 10 additions and 1 deletions

View File

@ -1946,7 +1946,10 @@ class YoutubeDL(object):
self.to_stdout(formatSeconds(info_dict['duration']))
print_mandatory('format')
if self.params.get('forcejson', False):
self.to_stdout(json.dumps(self.sanitize_info(info_dict)))
if self.params.get('indent_json', False):
self.to_stdout(json.dumps(self.sanitize_info(info_dict), indent=2))
else:
self.to_stdout(json.dumps(self.sanitize_info(info_dict)))
@_catch_unsafe_file_extension
def process_info(self, info_dict):

View File

@ -439,6 +439,7 @@ def _real_main(argv=None):
# just for deprecation check
'autonumber': opts.autonumber if opts.autonumber is True else None,
'usetitle': opts.usetitle if opts.usetitle is True else None,
'indent_json': opts.pretty_json,
}
with YoutubeDL(ydl_opts) as ydl:

View File

@ -679,6 +679,11 @@ def parseOpts(overrideArguments=None):
'--no-call-home',
dest='call_home', action='store_false', default=False,
help='Do NOT contact the youtube-dl server for debugging')
verbosity.add_option(
'--pretty-json',
dest='pretty_json', action='store_true', default=False,
help='Print json with indentation. Only when --dump-json is provided'
)
filesystem = optparse.OptionGroup(parser, 'Filesystem Options')
filesystem.add_option(