[core] Add option --get-manifest-url

This commit is contained in:
Thomas Uhle 2022-02-28 18:00:06 +01:00
parent 6508688e88
commit 7003699995
5 changed files with 15 additions and 1 deletions

View File

@ -301,6 +301,7 @@ Alternatively, refer to the [developer instructions](#developer-instructions) fo
write anything to disk
--skip-download Do not download the video
-g, --get-url Simulate, quiet but print URL
--get-manifest-url Simulate, quiet but print manifest URL
-e, --get-title Simulate, quiet but print title
--get-id Simulate, quiet but print id
--get-thumbnail Simulate, quiet but print thumbnail URL

View File

@ -4,6 +4,7 @@
"forcedescription": false,
"forcefilename": false,
"forceformat": false,
"forcemanifesturl": false,
"forcethumbnail": false,
"forcetitle": false,
"forceurl": false,

View File

@ -151,6 +151,7 @@ class YoutubeDL(object):
quiet: Do not print messages to stdout.
no_warnings: Do not print out anything for warnings.
forceurl: Force printing final URL.
forcemanifesturl: Force printing manifest URL.
forcetitle: Force printing title.
forceid: Force printing ID.
forcethumbnail: Force printing thumbnail URL.
@ -1763,6 +1764,12 @@ class YoutubeDL(object):
else:
# For RTMP URLs, also include the playpath
self.to_stdout(info_dict['url'] + info_dict.get('play_path', ''))
if self.params.get('forcemanifesturl', False) and not incomplete:
if info_dict.get('requested_formats') is not None:
for f in info_dict['requested_formats']:
self.to_stdout(f['manifest_url'])
else:
self.to_stdout(info_dict['manifest_url'])
print_optional('thumbnail')
print_optional('description')
if self.params.get('forcefilename', False) and filename is not None:

View File

@ -243,7 +243,7 @@ def _real_main(argv=None):
' file! Use "{0}.%(ext)s" instead of "{0}" as the output'
' template'.format(outtmpl))
any_getting = opts.geturl or opts.gettitle or opts.getid or opts.getthumbnail or opts.getdescription or opts.getfilename or opts.getformat or opts.getduration or opts.dumpjson or opts.dump_single_json
any_getting = opts.geturl or opts.getmanifesturl or opts.gettitle or opts.getid or opts.getthumbnail or opts.getdescription or opts.getfilename or opts.getformat or opts.getduration or opts.dumpjson or opts.dump_single_json
any_printing = opts.print_json
download_archive_fn = expand_path(opts.download_archive) if opts.download_archive is not None else opts.download_archive
@ -326,6 +326,7 @@ def _real_main(argv=None):
'quiet': (opts.quiet or any_getting or any_printing),
'no_warnings': opts.no_warnings,
'forceurl': opts.geturl,
'forcemanifesturl': opts.getmanifesturl,
'forcetitle': opts.gettitle,
'forceid': opts.getid,
'forcethumbnail': opts.getthumbnail,

View File

@ -594,6 +594,10 @@ def parseOpts(overrideArguments=None):
'-g', '--get-url',
action='store_true', dest='geturl', default=False,
help='Simulate, quiet but print URL')
verbosity.add_option(
'--get-manifest-url',
action='store_true', dest='getmanifesturl', default=False,
help='Simulate, quiet but print manifest URL')
verbosity.add_option(
'-e', '--get-title',
action='store_true', dest='gettitle', default=False,