diff --git a/README.md b/README.md index 47e686f84..456c93e76 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 9e5620eef..9938ec394 100755 --- a/youtube_dl/YoutubeDL.py +++ b/youtube_dl/YoutubeDL.py @@ -183,6 +183,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. @@ -1931,6 +1932,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 06bdfb689..e4966ce75 100644 --- a/youtube_dl/__init__.py +++ b/youtube_dl/__init__.py @@ -245,7 +245,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 @@ -328,6 +328,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 61705d1f0..2d8d95a03 100644 --- a/youtube_dl/options.py +++ b/youtube_dl/options.py @@ -598,6 +598,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,