From 70036999953dc95c3d92efb2ce01f0cc51982479 Mon Sep 17 00:00:00 2001 From: Thomas Uhle Date: Mon, 28 Feb 2022 18:00:06 +0100 Subject: [PATCH] [core] Add option --get-manifest-url --- README.md | 1 + test/parameters.json | 1 + youtube_dl/YoutubeDL.py | 7 +++++++ youtube_dl/__init__.py | 3 ++- youtube_dl/options.py | 4 ++++ 5 files changed, 15 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2841ed68f..c01140ac8 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/test/parameters.json b/test/parameters.json index 864c9d130..412221fd9 100644 --- a/test/parameters.json +++ b/test/parameters.json @@ -4,6 +4,7 @@ "forcedescription": false, "forcefilename": false, "forceformat": false, + "forcemanifesturl": false, "forcethumbnail": false, "forcetitle": false, "forceurl": false, diff --git a/youtube_dl/YoutubeDL.py b/youtube_dl/YoutubeDL.py index 69736acff..d7598167f 100755 --- a/youtube_dl/YoutubeDL.py +++ b/youtube_dl/YoutubeDL.py @@ -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: diff --git a/youtube_dl/__init__.py b/youtube_dl/__init__.py index e1bd67919..462946c5e 100644 --- a/youtube_dl/__init__.py +++ b/youtube_dl/__init__.py @@ -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, diff --git a/youtube_dl/options.py b/youtube_dl/options.py index 0a0641bd4..dbd9274c1 100644 --- a/youtube_dl/options.py +++ b/youtube_dl/options.py @@ -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,