X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;ds=sidebyside;f=youtube_dl%2Fextractor%2Fadobepass.py;h=38dca1b0a4c6891edeec4c225b9afc173048e1d5;hb=0c92f1e96b004fc7a04eac0759f115a535c8e03a;hp=a1584331526d459eaf9a8290217624a7fd8f1435;hpb=a9a346535bd855f4dd01aa32e54345cc741769c4;p=youtube-dl
diff --git a/youtube_dl/extractor/adobepass.py b/youtube_dl/extractor/adobepass.py
index a15843315..38dca1b0a 100644
--- a/youtube_dl/extractor/adobepass.py
+++ b/youtube_dl/extractor/adobepass.py
@@ -6,12 +6,16 @@ import time
import xml.etree.ElementTree as etree
from .common import InfoExtractor
-from ..compat import compat_urlparse
+from ..compat import (
+ compat_kwargs,
+ compat_urlparse,
+)
from ..utils import (
unescapeHTML,
urlencode_postdata,
unified_timestamp,
ExtractorError,
+ NO_DEFAULT,
)
@@ -21,6 +25,16 @@ MSO_INFO = {
'username_field': 'username',
'password_field': 'password',
},
+ 'ATT': {
+ 'name': 'AT&T U-verse',
+ 'username_field': 'userid',
+ 'password_field': 'password',
+ },
+ 'ATTOTT': {
+ 'name': 'DIRECTV NOW',
+ 'username_field': 'email',
+ 'password_field': 'loginpassword',
+ },
'Rogers': {
'name': 'Rogers',
'username_field': 'UserName',
@@ -36,6 +50,11 @@ MSO_INFO = {
'username_field': 'Ecom_User_ID',
'password_field': 'Ecom_Password',
},
+ 'Brighthouse': {
+ 'name': 'Bright House Networks | Spectrum',
+ 'username_field': 'j_username',
+ 'password_field': 'j_password',
+ },
'Charter_Direct': {
'name': 'Charter Spectrum',
'username_field': 'IDToken1',
@@ -1308,6 +1327,15 @@ class AdobePassIE(InfoExtractor):
_USER_AGENT = 'Mozilla/5.0 (X11; Linux i686; rv:47.0) Gecko/20100101 Firefox/47.0'
_MVPD_CACHE = 'ap-mvpd'
+ _DOWNLOADING_LOGIN_PAGE = 'Downloading Provider Login Page'
+
+ def _download_webpage_handle(self, *args, **kwargs):
+ headers = self.geo_verification_headers()
+ headers.update(kwargs.get('headers', {}))
+ kwargs['headers'] = headers
+ return super(AdobePassIE, self)._download_webpage_handle(
+ *args, **compat_kwargs(kwargs))
+
@staticmethod
def _get_mvpd_resource(provider_id, title, guid, rating):
channel = etree.Element('channel')
@@ -1350,6 +1378,21 @@ class AdobePassIE(InfoExtractor):
'Use --ap-mso to specify Adobe Pass Multiple-system operator Identifier '
'and --ap-username and --ap-password or --netrc to provide account credentials.', expected=True)
+ def extract_redirect_url(html, url=None, fatal=False):
+ # TODO: eliminate code duplication with generic extractor and move
+ # redirection code into _download_webpage_handle
+ REDIRECT_REGEX = r'[0-9]{,2};\s*(?:URL|url)=\'?([^\'"]+)'
+ redirect_url = self._search_regex(
+ r'(?i)Resume' in mvpd_confirm_page:
post_form(mvpd_confirm_page_res, 'Confirming Login')
-
elif mso_id == 'Verizon':
# 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
- # print('provider_redirect_page_url', urlh.geturl())
- # https://signin.verizon.com/sso/VOLPortalLogin?SAMLRequest=
if 'Please wait ...' in provider_redirect_page:
- # print('[debug] SAML Auto-Login is TRUE') # GO,
saml_redirect_url = self._html_search_regex(
r'self\.parent\.location=(["\'])(?P.+?)\1',
- provider_redirect_page, 'Extracting SAML Redirect URL', group='url'
- )
- # print('saml_redirect_url', saml_redirect_url)
- # https://signin.verizon.com/sso/choice/tvpHandler.jsp?loginType=vzRedirect&partner=
+ provider_redirect_page,
+ 'SAML Redirect URL', group='url')
saml_login_page = self._download_webpage(
- saml_redirect_url, video_id, 'Downloading SAML Login Page'
- )
+ saml_redirect_url, video_id,
+ 'Downloading SAML Login Page')
else:
- if 'Please try again.' in provider_redirect_page:
- # print('[debug] SAML Auto-Login is FALSE') # NBC,
- provider_login_page_res = provider_redirect_page_res
- else:
- print('[error] SAML Auto-Login is UNKNOWN')
- import sys
- sys.exit(1)
- provider_login_page, urlh = provider_login_page_res
- # print('provider_login_page_url', urlh.geturl())
- # https://signin.verizon.com/sso/VOLPortalLogin?SAMLRequest=
- saml_login_page_res = post_form(provider_login_page_res, 'Logging in', {
- mso_info.get('username_field', 'username'): username,
- mso_info.get('password_field', 'password'): password,
- })
+ saml_login_page_res = post_form(
+ provider_redirect_page_res, 'Logging in', {
+ mso_info['username_field']: username,
+ mso_info['password_field']: password,
+ })
saml_login_page, urlh = saml_login_page_res
if 'Please try again.' in saml_login_page:
- print("[error] We're sorry, but either the User ID or Password entered is not correct.")
- import sys
- sys.exit(1)
- # elif 'Please wait - we are verifying your account...' in saml_login_page:
- # print('saml_login_page_url', urlh.geturl())
- # https://signin.verizon.com/sso/choice/tvpHandler.jsp?loginType=vzRedirect&partner=
- saml_login_url = self._html_search_regex(
- r'xmlHttp\.open\(\"POST\",\s(["\'])(?P.+?)\1',
- saml_login_page, 'Extracting SAML Login URL', group='url')
- # print('saml_login_url', saml_login_url)
- # https://signin.verizon.com/sso/TVPHandlerServlet?loginType=vzRedirect&partner=
+ raise ExtractorError(
+ 'We\'re sorry, but either the User ID or Password entered is not correct.')
+ saml_login_url = self._search_regex(
+ r'xmlHttp\.open\("POST"\s*,\s*(["\'])(?P.+?)\1',
+ saml_login_page, 'SAML Login URL', group='url')
saml_response_json = self._download_json(
saml_login_url, video_id, 'Downloading SAML Response',
- headers={'Content-Type': 'text/xml'}
- )
- saml_target_url = saml_response_json['targetValue']
- saml_response = saml_response_json['SAMLResponse']
- saml_relay_state = saml_response_json['RelayState']
- # print('saml_target_url', saml_target_url)
- # https://sp.auth.adobe.com/sp/saml/SAMLAssertionConsumer
- form_data = {
- 'SAMLResponse': saml_response,
- 'RelayState': saml_relay_state
- }
- saml_autologin_res = self._download_webpage_handle(
- saml_target_url, video_id,
- 'Auto-Login', data=urlencode_postdata(form_data),
- headers={'Content-Type': 'application/x-www-form-urlencoded'}
- )
- original_page, urlh = saml_autologin_res
- # print('original_page_url', urlh.geturl())
-
+ headers={'Content-Type': 'text/xml'})
+ self._download_webpage(
+ saml_response_json['targetValue'], video_id,
+ 'Confirming Login', data=urlencode_postdata({
+ 'SAMLResponse': saml_response_json['SAMLResponse'],
+ 'RelayState': saml_response_json['RelayState']
+ }), headers={
+ 'Content-Type': 'application/x-www-form-urlencoded'
+ })
else:
- # Normal, non-Comcast flow
+ # Some providers (e.g. DIRECTV NOW) have another meta refresh
+ # based redirect that should be followed.
+ provider_redirect_page, urlh = provider_redirect_page_res
+ provider_refresh_redirect_url = extract_redirect_url(
+ provider_redirect_page, url=urlh.geturl())
+ if provider_refresh_redirect_url:
+ provider_redirect_page_res = self._download_webpage_handle(
+ provider_refresh_redirect_url, video_id,
+ 'Downloading Provider Redirect Page (meta refresh)')
provider_login_page_res = post_form(
- provider_redirect_page_res, 'Downloading Provider Login Page')
+ provider_redirect_page_res, self._DOWNLOADING_LOGIN_PAGE)
mvpd_confirm_page_res = post_form(provider_login_page_res, 'Logging in', {
mso_info.get('username_field', 'username'): username,
mso_info.get('password_field', 'password'): password,