mirror of
				https://github.com/yt-dlp/yt-dlp.git
				synced 2025-10-31 14:45:14 +00:00 
			
		
		
		
	[udemy] Handle already-logged-in scenario (Closes #6327)
This commit is contained in:
		| @@ -77,7 +77,11 @@ class UdemyIE(InfoExtractor): | |||||||
|         login_popup = self._download_webpage( |         login_popup = self._download_webpage( | ||||||
|             self._LOGIN_URL, None, 'Downloading login popup') |             self._LOGIN_URL, None, 'Downloading login popup') | ||||||
|  |  | ||||||
|         if login_popup == '<div class="run-command close-popup redirect" data-url="https://www.udemy.com/"></div>': |         def is_logged(webpage): | ||||||
|  |             return any(p in webpage for p in ['href="https://www.udemy.com/user/logout/', '>Logout<']) | ||||||
|  |  | ||||||
|  |         # already logged in | ||||||
|  |         if is_logged(login_popup): | ||||||
|             return |             return | ||||||
|  |  | ||||||
|         login_form = self._form_hidden_inputs('login-form', login_popup) |         login_form = self._form_hidden_inputs('login-form', login_popup) | ||||||
| @@ -95,8 +99,7 @@ class UdemyIE(InfoExtractor): | |||||||
|         response = self._download_webpage( |         response = self._download_webpage( | ||||||
|             request, None, 'Logging in as %s' % username) |             request, None, 'Logging in as %s' % username) | ||||||
|  |  | ||||||
|         if all(logout_pattern not in response |         if not is_logged(response): | ||||||
|                for logout_pattern in ['href="https://www.udemy.com/user/logout/', '>Logout<']): |  | ||||||
|             error = self._html_search_regex( |             error = self._html_search_regex( | ||||||
|                 r'(?s)<div[^>]+class="form-errors[^"]*">(.+?)</div>', |                 r'(?s)<div[^>]+class="form-errors[^"]*">(.+?)</div>', | ||||||
|                 response, 'error message', default=None) |                 response, 'error message', default=None) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Sergey M․
					Sergey M․