[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 write anything to disk
--skip-download Do not download the video --skip-download Do not download the video
-g, --get-url Simulate, quiet but print URL -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 -e, --get-title Simulate, quiet but print title
--get-id Simulate, quiet but print id --get-id Simulate, quiet but print id
--get-thumbnail Simulate, quiet but print thumbnail URL --get-thumbnail Simulate, quiet but print thumbnail URL

View File

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

View File

@ -151,6 +151,7 @@ class YoutubeDL(object):
quiet: Do not print messages to stdout. quiet: Do not print messages to stdout.
no_warnings: Do not print out anything for warnings. no_warnings: Do not print out anything for warnings.
forceurl: Force printing final URL. forceurl: Force printing final URL.
forcemanifesturl: Force printing manifest URL.
forcetitle: Force printing title. forcetitle: Force printing title.
forceid: Force printing ID. forceid: Force printing ID.
forcethumbnail: Force printing thumbnail URL. forcethumbnail: Force printing thumbnail URL.
@ -1763,6 +1764,12 @@ class YoutubeDL(object):
else: else:
# For RTMP URLs, also include the playpath # For RTMP URLs, also include the playpath
self.to_stdout(info_dict['url'] + info_dict.get('play_path', '')) 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('thumbnail')
print_optional('description') print_optional('description')
if self.params.get('forcefilename', False) and filename is not None: 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' ' file! Use "{0}.%(ext)s" instead of "{0}" as the output'
' template'.format(outtmpl)) ' 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 any_printing = opts.print_json
download_archive_fn = expand_path(opts.download_archive) if opts.download_archive is not None else opts.download_archive 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), 'quiet': (opts.quiet or any_getting or any_printing),
'no_warnings': opts.no_warnings, 'no_warnings': opts.no_warnings,
'forceurl': opts.geturl, 'forceurl': opts.geturl,
'forcemanifesturl': opts.getmanifesturl,
'forcetitle': opts.gettitle, 'forcetitle': opts.gettitle,
'forceid': opts.getid, 'forceid': opts.getid,
'forcethumbnail': opts.getthumbnail, 'forcethumbnail': opts.getthumbnail,

View File

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