mirror of
				https://github.com/yt-dlp/yt-dlp.git
				synced 2025-10-30 22:25:19 +00:00 
			
		
		
		
	Add option --cookies-from-browser to load cookies from a browser (#488)
				
					
				
			* also adds `--no-cookies-from-browser` Original PR: https://github.com/ytdl-org/youtube-dl/pull/29201 Authored by: mbway
This commit is contained in:
		| @@ -31,7 +31,6 @@ from zipimport import zipimporter | ||||
|  | ||||
| from .compat import ( | ||||
|     compat_basestring, | ||||
|     compat_cookiejar, | ||||
|     compat_get_terminal_size, | ||||
|     compat_kwargs, | ||||
|     compat_numeric_types, | ||||
| @@ -42,6 +41,7 @@ from .compat import ( | ||||
|     compat_urllib_request, | ||||
|     compat_urllib_request_DataHandler, | ||||
| ) | ||||
| from .cookies import load_cookies | ||||
| from .utils import ( | ||||
|     age_restricted, | ||||
|     args_to_str, | ||||
| @@ -110,7 +110,6 @@ from .utils import ( | ||||
|     version_tuple, | ||||
|     write_json_file, | ||||
|     write_string, | ||||
|     YoutubeDLCookieJar, | ||||
|     YoutubeDLCookieProcessor, | ||||
|     YoutubeDLHandler, | ||||
|     YoutubeDLRedirectHandler, | ||||
| @@ -290,6 +289,9 @@ class YoutubeDL(object): | ||||
|     break_on_reject:   Stop the download process when encountering a video that | ||||
|                        has been filtered out. | ||||
|     cookiefile:        File name where cookies should be read from and dumped to | ||||
|     cookiesfrombrowser: A tuple containing the name of the browser and the profile | ||||
|                        name/path from where cookies are loaded. | ||||
|                        Eg: ('chrome', ) or (vivaldi, 'default') | ||||
|     nocheckcertificate:Do not verify SSL certificates | ||||
|     prefer_insecure:   Use HTTP instead of HTTPS to retrieve information. | ||||
|                        At the moment, this is only supported by YouTube. | ||||
| @@ -3211,16 +3213,11 @@ class YoutubeDL(object): | ||||
|         timeout_val = self.params.get('socket_timeout') | ||||
|         self._socket_timeout = 600 if timeout_val is None else float(timeout_val) | ||||
|  | ||||
|         opts_cookiesfrombrowser = self.params.get('cookiesfrombrowser') | ||||
|         opts_cookiefile = self.params.get('cookiefile') | ||||
|         opts_proxy = self.params.get('proxy') | ||||
|  | ||||
|         if opts_cookiefile is None: | ||||
|             self.cookiejar = compat_cookiejar.CookieJar() | ||||
|         else: | ||||
|             opts_cookiefile = expand_path(opts_cookiefile) | ||||
|             self.cookiejar = YoutubeDLCookieJar(opts_cookiefile) | ||||
|             if os.access(opts_cookiefile, os.R_OK): | ||||
|                 self.cookiejar.load(ignore_discard=True, ignore_expires=True) | ||||
|         self.cookiejar = load_cookies(opts_cookiefile, opts_cookiesfrombrowser, self) | ||||
|  | ||||
|         cookie_processor = YoutubeDLCookieProcessor(self.cookiejar) | ||||
|         if opts_proxy is not None: | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Matt Broadway
					Matt Broadway