mirror of
				https://github.com/yt-dlp/yt-dlp.git
				synced 2025-10-31 06:35:12 +00:00 
			
		
		
		
	Standardize write_debug
				
					
				
			This commit is contained in:
		| @@ -542,8 +542,7 @@ class YoutubeDL(object): | ||||
|         def preload_download_archive(fn): | ||||
|             if fn is None: | ||||
|                 return False | ||||
|             if self.params.get('verbose'): | ||||
|                 self._write_string('[debug] Loading archive file %r\n' % fn) | ||||
|             self.write_debug('Loading archive file %r\n' % fn) | ||||
|             try: | ||||
|                 with locked_file(fn, 'r', encoding='utf-8') as archive_file: | ||||
|                     for line in archive_file: | ||||
| @@ -649,17 +648,11 @@ class YoutubeDL(object): | ||||
|                       for _ in range(line_count)) | ||||
|         return res[:-len('\n')] | ||||
|  | ||||
|     def to_screen(self, message, skip_eol=False): | ||||
|         """Print message to stdout if not in quiet mode.""" | ||||
|         return self.to_stdout( | ||||
|             message, skip_eol, | ||||
|             quiet=self.params.get('quiet', False)) | ||||
|  | ||||
|     def _write_string(self, s, out=None): | ||||
|         write_string(s, out=out, encoding=self.params.get('encoding')) | ||||
|  | ||||
|     def to_stdout(self, message, skip_eol=False, quiet=False): | ||||
|         """Print message to stdout if not in quiet mode.""" | ||||
|         """Print message to stdout""" | ||||
|         if self.params.get('logger'): | ||||
|             self.params['logger'].debug(message) | ||||
|         elif not quiet: | ||||
| @@ -670,7 +663,7 @@ class YoutubeDL(object): | ||||
|             self._write_string(output, self._screen_file) | ||||
|  | ||||
|     def to_stderr(self, message): | ||||
|         """Print message to stderr.""" | ||||
|         """Print message to stderr""" | ||||
|         assert isinstance(message, compat_str) | ||||
|         if self.params.get('logger'): | ||||
|             self.params['logger'].error(message) | ||||
| @@ -748,6 +741,11 @@ class YoutubeDL(object): | ||||
|             raise DownloadError(message, exc_info) | ||||
|         self._download_retcode = 1 | ||||
|  | ||||
|     def to_screen(self, message, skip_eol=False): | ||||
|         """Print message to stdout if not in quiet mode""" | ||||
|         self.to_stdout( | ||||
|             message, skip_eol, quiet=self.params.get('quiet', False)) | ||||
|  | ||||
|     def report_warning(self, message): | ||||
|         ''' | ||||
|         Print the message to stderr, it will be prefixed with 'WARNING:' | ||||
| @@ -777,6 +775,16 @@ class YoutubeDL(object): | ||||
|         error_message = '%s %s' % (_msg_header, message) | ||||
|         self.trouble(error_message, tb) | ||||
|  | ||||
|     def write_debug(self, message): | ||||
|         '''Log debug message or Print message to stderr''' | ||||
|         if not self.params.get('verbose', False): | ||||
|             return | ||||
|         message = '[debug] %s' % message | ||||
|         if self.params.get('logger'): | ||||
|             self.params['logger'].debug(message) | ||||
|         else: | ||||
|             self._write_string('%s\n' % message) | ||||
|  | ||||
|     def report_file_already_downloaded(self, file_name): | ||||
|         """Report file has already been fully downloaded.""" | ||||
|         try: | ||||
| @@ -2081,8 +2089,7 @@ class YoutubeDL(object): | ||||
|         req_format = self.params.get('format') | ||||
|         if req_format is None: | ||||
|             req_format = self._default_format_spec(info_dict, download=download) | ||||
|             if self.params.get('verbose'): | ||||
|                 self.to_screen('[debug] Default format spec: %s' % req_format) | ||||
|             self.write_debug('Default format spec: %s' % req_format) | ||||
|  | ||||
|         format_selector = self.build_format_selector(req_format) | ||||
|  | ||||
| @@ -2249,8 +2256,7 @@ class YoutubeDL(object): | ||||
|         if not test: | ||||
|             for ph in self._progress_hooks: | ||||
|                 fd.add_progress_hook(ph) | ||||
|             if self.params.get('verbose'): | ||||
|                 self.to_screen('[debug] Invoking downloader on %r' % info.get('url')) | ||||
|             self.write_debug('Invoking downloader on %r' % info.get('url')) | ||||
|         new_info = dict(info) | ||||
|         if new_info.get('http_headers') is None: | ||||
|             new_info['http_headers'] = self._calc_headers(new_info) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 pukkandan
					pukkandan