From 52a2f994c95ed26c8b6d0b3b70b61379572e978c Mon Sep 17 00:00:00 2001 From: nyuszika7h Date: Mon, 23 Aug 2021 02:38:32 +0200 Subject: [PATCH] [adobepass] Fix Verizon SAML login (#743) Original PR: https://github.com/ytdl-org/youtube-dl/pull/19136 from https://bitbucket.org/ParadoxGBB/youtube-dl/commits/64bddfe15c1458a1b3461875bf9afd0a17ebeea0 Authored-by: nyuszika7h, ParadoxGBB --- yt_dlp/extractor/adobepass.py | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/yt_dlp/extractor/adobepass.py b/yt_dlp/extractor/adobepass.py index 4272e5605..ffab33294 100644 --- a/yt_dlp/extractor/adobepass.py +++ b/yt_dlp/extractor/adobepass.py @@ -1508,7 +1508,8 @@ def extract_redirect_url(html, url=None, fatal=False): # In general, if you're connecting from a Verizon-assigned IP, # you will not actually pass your credentials. provider_redirect_page, urlh = provider_redirect_page_res - if 'Please wait ...' in provider_redirect_page: + # From non-Verizon IP, still gave 'Please wait', but noticed N==Y; will need to try on Verizon IP + if 'Please wait ...' in provider_redirect_page and '\'N\'== "Y"' not in provider_redirect_page: saml_redirect_url = self._html_search_regex( r'self\.parent\.location=(["\'])(?P.+?)\1', provider_redirect_page, @@ -1516,7 +1517,8 @@ def extract_redirect_url(html, url=None, fatal=False): saml_login_page = self._download_webpage( saml_redirect_url, video_id, 'Downloading SAML Login Page') - else: + elif 'Verizon FiOS - sign in' in provider_redirect_page: + # FXNetworks from non-Verizon IP saml_login_page_res = post_form( provider_redirect_page_res, 'Logging in', { mso_info['username_field']: username, @@ -1526,6 +1528,26 @@ def extract_redirect_url(html, url=None, fatal=False): if 'Please try again.' in saml_login_page: raise ExtractorError( 'We\'re sorry, but either the User ID or Password entered is not correct.') + else: + # ABC from non-Verizon IP + saml_redirect_url = self._html_search_regex( + r'var\surl\s*=\s*(["\'])(?P.+?)\1', + provider_redirect_page, + 'SAML Redirect URL', group='url') + saml_redirect_url = saml_redirect_url.replace(r'\/', '/') + saml_redirect_url = saml_redirect_url.replace(r'\-', '-') + saml_redirect_url = saml_redirect_url.replace(r'\x26', '&') + saml_login_page = self._download_webpage( + saml_redirect_url, video_id, + 'Downloading SAML Login Page') + saml_login_page, urlh = post_form( + [saml_login_page, saml_redirect_url], 'Logging in', { + mso_info['username_field']: username, + mso_info['password_field']: password, + }) + if 'Please try again.' in saml_login_page: + raise ExtractorError( + 'Failed to login, incorrect User ID or Password.') saml_login_url = self._search_regex( r'xmlHttp\.open\("POST"\s*,\s*(["\'])(?P.+?)\1', saml_login_page, 'SAML Login URL', group='url')