From 463a7e1bdd88e5ab69079c3d5c564808a0285e84 Mon Sep 17 00:00:00 2001 From: krvmk Date: Mon, 25 Feb 2019 08:48:37 -0600 Subject: [PATCH] Add support for Google Fiber to adobepass.py --- youtube_dl/extractor/adobepass.py | 49 +++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/youtube_dl/extractor/adobepass.py b/youtube_dl/extractor/adobepass.py index 1cf2dcbf3..3fdb9d67c 100644 --- a/youtube_dl/extractor/adobepass.py +++ b/youtube_dl/extractor/adobepass.py @@ -1314,6 +1314,9 @@ MSO_INFO = { 'cou060': { 'name': 'Zito Media' }, + 'GoogleFiber': { + 'name': 'Google Fiber Direct' + }, } @@ -1491,6 +1494,52 @@ class AdobePassIE(InfoExtractor): }), headers={ 'Content-Type': 'application/x-www-form-urlencoded' }) + elif mso_id == 'GoogleFiber': + # Google Fiber uses a series of web calls and a click through + # only valid if you are connecting from a Google Fiber IP address + # TODO: handle username/password authentication if remote + provider_redirect_page, urlh = provider_redirect_page_res + if 'history_val' in provider_redirect_page: + saml_firstbookend_url = urlh.geturl() + saml_autoauth_page = self._download_webpage( + saml_firstbookend_url, 'First Bookend Redirect', query={ + 'history': '17', + }) + if '$.ajax(' in saml_autoauth_page: + saml_ajaxautoauth_url = self._html_search_regex( + r'url\s*:\s*(["\'])(?P.+?)\1', + saml_autoauth_page, + 'SAML Redirect URL', group='url' + ) + saml_login_url = self._html_search_regex( + r'window.location.replace\((["\'])(?P.+?login.php)\1', + saml_autoauth_page, + 'Auth Redirect URL', group='url' + ) + saml_ajaxcall_page = self._download_webpage( + saml_ajaxautoauth_url, 'SAML Autoauth') + saml_login_res = self._download_webpage_handle( + saml_login_url + '?AuthState=%s' % saml_ajaxcall_page, + 'SAML Login') + provider_postlogin_page_res = post_form(saml_login_res, 'SAML Accept Login') + provider_postlogin_page, urlh = provider_postlogin_page_res + saml_redirect_url = extract_redirect_url( + provider_postlogin_page, fatal=True) + provider_finallogin_page_res = self._download_webpage_handle( + saml_redirect_url, video_id, + 'SAML Final Redirect') + provider_page, urlh = provider_finallogin_page_res + saml_lastbookend_url = urlh.geturl() + saml_finalredirect_page_res = self._download_webpage_handle( + saml_lastbookend_url, 'SAML Final', query={ + 'history': '19', + } + ) + post_form(saml_finalredirect_page_res, 'SAML Response') + else: + raise ExtractorError( + 'Unable to automatically login with GoogleFiber. Maybe not a Google Fiber IP?' + ) else: # Some providers (e.g. DIRECTV NOW) have another meta refresh # based redirect that should be followed.