mirror of
				https://github.com/yt-dlp/yt-dlp.git
				synced 2025-10-31 06:35:12 +00:00 
			
		
		
		
	Move option warnings to YoutubeDL
				
					
				
			Previously, these warnings did not obey `--no-warnings` and did not output colors
This commit is contained in:
		| @@ -474,6 +474,13 @@ class YoutubeDL(object): | |||||||
|             if self.params.get('geo_verification_proxy') is None: |             if self.params.get('geo_verification_proxy') is None: | ||||||
|                 self.params['geo_verification_proxy'] = self.params['cn_verification_proxy'] |                 self.params['geo_verification_proxy'] = self.params['cn_verification_proxy'] | ||||||
|  |  | ||||||
|  |         check_deprecated('autonumber_size', '--autonumber-size', 'output template with %(autonumber)0Nd, where N in the number of digits') | ||||||
|  |         check_deprecated('autonumber', '--auto-number', '-o "%(autonumber)s-%(title)s.%(ext)s"') | ||||||
|  |         check_deprecated('usetitle', '--title', '-o "%(title)s-%(id)s.%(ext)s"') | ||||||
|  |  | ||||||
|  |         for msg in self.params.get('warnings', []): | ||||||
|  |             self.report_warning(msg) | ||||||
|  |  | ||||||
|         if self.params.get('final_ext'): |         if self.params.get('final_ext'): | ||||||
|             if self.params.get('merge_output_format'): |             if self.params.get('merge_output_format'): | ||||||
|                 self.report_warning('--merge-output-format will be ignored since --remux-video or --recode-video is given') |                 self.report_warning('--merge-output-format will be ignored since --remux-video or --recode-video is given') | ||||||
| @@ -482,10 +489,6 @@ class YoutubeDL(object): | |||||||
|         if 'overwrites' in self.params and self.params['overwrites'] is None: |         if 'overwrites' in self.params and self.params['overwrites'] is None: | ||||||
|             del self.params['overwrites'] |             del self.params['overwrites'] | ||||||
|  |  | ||||||
|         check_deprecated('autonumber_size', '--autonumber-size', 'output template with %(autonumber)0Nd, where N in the number of digits') |  | ||||||
|         check_deprecated('autonumber', '--auto-number', '-o "%(autonumber)s-%(title)s.%(ext)s"') |  | ||||||
|         check_deprecated('usetitle', '--title', '-o "%(title)s-%(id)s.%(ext)s"') |  | ||||||
|  |  | ||||||
|         if params.get('bidi_workaround', False): |         if params.get('bidi_workaround', False): | ||||||
|             try: |             try: | ||||||
|                 import pty |                 import pty | ||||||
|   | |||||||
| @@ -60,6 +60,7 @@ def _real_main(argv=None): | |||||||
|     setproctitle('yt-dlp') |     setproctitle('yt-dlp') | ||||||
|  |  | ||||||
|     parser, opts, args = parseOpts(argv) |     parser, opts, args = parseOpts(argv) | ||||||
|  |     warnings = [] | ||||||
|  |  | ||||||
|     # Set user agent |     # Set user agent | ||||||
|     if opts.user_agent is not None: |     if opts.user_agent is not None: | ||||||
| @@ -281,7 +282,7 @@ def _real_main(argv=None): | |||||||
|         opts.writeinfojson = True |         opts.writeinfojson = True | ||||||
|  |  | ||||||
|     def report_conflict(arg1, arg2): |     def report_conflict(arg1, arg2): | ||||||
|         write_string('WARNING: %s is ignored since %s was given\n' % (arg2, arg1), out=sys.stderr) |         warnings.append('%s is ignored since %s was given' % (arg2, arg1)) | ||||||
|  |  | ||||||
|     if opts.remuxvideo and opts.recodevideo: |     if opts.remuxvideo and opts.recodevideo: | ||||||
|         report_conflict('--recode-video', '--remux-video') |         report_conflict('--recode-video', '--remux-video') | ||||||
| @@ -419,11 +420,10 @@ def _real_main(argv=None): | |||||||
|         }) |         }) | ||||||
|  |  | ||||||
|     def report_args_compat(arg, name): |     def report_args_compat(arg, name): | ||||||
|         write_string( |         warnings.append('%s given without specifying name. The arguments will be given to all %s' % (arg, name)) | ||||||
|             'WARNING: %s given without specifying name. The arguments will be given to all %s\n' % (arg, name), |  | ||||||
|             out=sys.stderr) |  | ||||||
|     if 'default' in opts.external_downloader_args: |     if 'default' in opts.external_downloader_args: | ||||||
|         report_args_compat('--external-downloader-args', 'external downloaders') |         report_args_compat('--downloader-args', 'external downloaders') | ||||||
|  |  | ||||||
|     if 'default-compat' in opts.postprocessor_args and 'default' not in opts.postprocessor_args: |     if 'default-compat' in opts.postprocessor_args and 'default' not in opts.postprocessor_args: | ||||||
|         report_args_compat('--post-processor-args', 'post-processors') |         report_args_compat('--post-processor-args', 'post-processors') | ||||||
| @@ -589,8 +589,9 @@ def _real_main(argv=None): | |||||||
|         'geo_bypass_country': opts.geo_bypass_country, |         'geo_bypass_country': opts.geo_bypass_country, | ||||||
|         'geo_bypass_ip_block': opts.geo_bypass_ip_block, |         'geo_bypass_ip_block': opts.geo_bypass_ip_block, | ||||||
|         # just for deprecation check |         # just for deprecation check | ||||||
|         'autonumber': opts.autonumber if opts.autonumber is True else None, |         'warnings': warnings, | ||||||
|         'usetitle': opts.usetitle if opts.usetitle is True else None, |         'autonumber': opts.autonumber or None, | ||||||
|  |         'usetitle': opts.usetitle or None, | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     with YoutubeDL(ydl_opts) as ydl: |     with YoutubeDL(ydl_opts) as ydl: | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 pukkandan
					pukkandan