2 from __future__
import unicode_literals
7 import xml
.etree
.ElementTree
as etree
9 from .common
import InfoExtractor
10 from ..compat
import (
26 'username_field': 'username',
27 'password_field': 'password',
30 'name': 'AT&T U-verse',
31 'username_field': 'userid',
32 'password_field': 'password',
35 'name': 'DIRECTV NOW',
36 'username_field': 'email',
37 'password_field': 'loginpassword',
41 'username_field': 'username',
42 'password_field': 'password',
46 'username_field': 'UserName',
47 'password_field': 'UserPassword',
50 'name': 'Comcast XFINITY',
51 'username_field': 'user',
52 'password_field': 'passwd',
55 'name': 'Time Warner Cable | Spectrum',
56 'username_field': 'Ecom_User_ID',
57 'password_field': 'Ecom_Password',
60 'name': 'Bright House Networks | Spectrum',
61 'username_field': 'j_username',
62 'password_field': 'j_password',
65 'name': 'Charter Spectrum',
66 'username_field': 'IDToken1',
67 'password_field': 'IDToken2',
71 'username_field': 'IDToken1',
72 'password_field': 'IDToken2',
76 'username_field': 'ident'
79 'name': 'Verizon FiOS',
80 'username_field': 'IDToken1',
81 'password_field': 'IDToken2',
84 'name': 'Optimum/Cablevision',
85 'username_field': 'j_username',
86 'password_field': 'j_password',
89 'name': '3 Rivers Communications'
92 'name': 'Access Montana'
94 'acecommunications': {
98 'name': 'Acme Communications'
101 'name': 'Adams Cable Service'
104 'name': 'Albany Mutual Telephone'
107 'name': 'Algona Municipal Utilities'
110 'name': 'All West Communications'
113 'name': 'Allen\'s Communications'
116 'name': 'Alliance Communications'
119 'name': 'ALLO Communications'
122 'name': 'Alpine Communications'
125 'name': 'American Broadband'
128 'name': 'American Broadband Missouri'
131 'name': 'American Community Networks'
134 'name': 'American Warrior Networks'
137 'name': 'Amherst Telephone/Tomorrow Valley'
143 'name': 'Arkwest Communications'
146 'name': 'Arthur Mutual Telephone Company'
152 'name': 'Ashland Home Net'
155 'name': 'Astound (now Wave)'
158 'name': 'ATC Broadband'
161 'name': 'ATC Communications'
164 'name': 'Ayersville Communications'
167 'name': 'Baldwin Lightstream'
173 'name': 'Bardstown Cable TV'
176 'name': 'Bay Country Communications'
179 'name': 'Beaver Creek Cooperative Telephone'
182 'name': 'Beaver Valley Cable'
185 'name': 'Bee Line Cable'
188 'name': 'Beehive Broadband'
194 'name': 'Bellevue Municipal Cable'
197 'name': 'Ben Lomand Connect / BLTV'
203 'name': 'Big Sandy Broadband'
206 'name': 'Bledsoe Telephone Cooperative'
209 'name': 'Blue Valley Tele-Communications'
212 'name': 'Brandenburg Telephone Co.'
215 'name': 'Bristol Tennessee Essential Services'
218 'name': 'Broadstripe'
221 'name': 'BTC Communications'
224 'name': 'BTC Vision - Nahunta'
227 'name': 'Bulloch Telephone Cooperative'
230 'name': 'Butler-Bremer Communications'
233 'name': 'C Spire SNAP'
236 'name': 'Cable Services Inc.'
239 'name': 'CableAmerica'
242 'name': 'CableSouth Media 3'
245 'name': 'Cam-Tel Company'
248 'name': 'Cameron Communications'
251 'name': 'Canby Telcom'
257 'name': 'Carnegie Cable'
266 'name': 'Catalina Broadband Solutions'
269 'name': 'CC Communications'
272 'name': 'CDE Lightband'
275 'name': 'Cedar Falls Utilities'
278 'name': 'Celect-Bloomer Telephone Area'
281 'name': 'Celect-Bruce Telephone Area'
284 'name': 'Celect-Citizens Connected Area'
287 'name': 'Celect-Elmwood/Spring Valley Area'
290 'name': 'Celect-Mosaic Telecom'
293 'name': 'Celect-West WI Telephone Area'
296 'name': 'Cellcom/Nsight Telservices'
302 'name': 'Central Scott / CSTV'
305 'name': 'Chaparral CableVision'
308 'name': 'Chariton Valley Communication Corporation, Inc.'
311 'name': 'Chatmoss Cablevision'
314 'name': 'Cherokee Communications'
317 'name': 'Chesapeake Bay Communications'
320 'name': 'Cim-Tel Cable, LLC.'
323 'name': 'Citizens Cablevision - Floyd, VA'
326 'name': 'Citizens Cablevision, Inc.'
329 'name': 'Citizens Fiber'
332 'name': 'Citizens Mutual'
335 'name': 'Citizens Telephone Corporation'
338 'name': 'City Of Monroe'
347 'name': 'Clarence Telephone and Cedar Communications'
350 'name': 'Clear Choice Communications'
353 'name': 'Click! Cable TV'
359 'name': 'CML Telephone Cooperative Association'
365 'name': 'Co-Mo Connect'
368 'name': 'Coast Communications'
371 'name': 'Coaxial Cable TV'
374 'name': 'Cobalt TV (Mid-State Community TV)'
377 'name': 'Columbia Power & Water Systems'
380 'name': 'Columbus Telephone'
383 'name': 'Communications 1 Cablevision, Inc.'
386 'name': 'Community Cable & Broadband'
389 'name': 'Community Communications Company'
395 'name': 'Complete Communication Services'
401 'name': 'ComSouth Telesys'
403 'consolidatedcable': {
404 'name': 'Consolidated'
407 'name': 'Conway Corporation'
410 'name': 'Coon Valley Telecommunications Inc'
413 'name': 'Cooperative Telephone Company'
419 'name': 'Craw-Kan Telephone'
422 'name': 'Crestview Cable Communications'
428 'name': 'Crosslake Communications'
431 'name': 'CTC - Brainerd MN'
434 'name': 'CTV-Beam - East Alabama'
437 'name': 'Cunningham Telephone & Cable'
440 'name': 'D & P Communications'
443 'name': 'Dakota Central Telecommunications'
446 'name': 'Delcambre Telephone LLC'
449 'name': 'Delta Telephone Company'
455 'name': 'Direct Communications'
458 'name': 'Doylestown Cable TV'
467 'name': 'DTC Cable (Delhi)'
470 'name': 'Dumont Telephone Company'
473 'name': 'Dunkerton Telephone Cooperative'
476 'name': 'Duo County Telecom'
479 'name': 'Eagle Communications'
482 'name': 'East Arkansas Cable TV'
485 'name': 'EATEL Video, LLC'
491 'name': 'Emery Telcom Video LLC'
494 'name': 'Empire Access'
497 'name': 'Endeavor Communications'
500 'name': 'Enhanced Telecommunications Corporation'
506 'name': 'EPB Smartnet'
509 'name': 'EPlus Broadband'
515 'name': 'Etex Communications'
518 'name': 'F&B Communications'
521 'name': 'Falcon Broadband'
524 'name': 'FamilyView CableVision'
527 'name': 'Farmers Mutual Telephone Company'
530 'name': 'Fayetteville Public Utilities'
536 'name': 'Fidelity Communications'
539 'name': 'FJ Communications'
542 'name': 'Flint River Communications'
545 'name': 'FMT - Jesup'
548 'name': 'Foothills Communications'
551 'name': 'Forsyth CableNet'
554 'name': 'Frankfort Plant Board'
557 'name': 'Franklin Telephone Company'
563 'name': 'Full Channel, Inc.'
566 'name': 'Gardonville Cooperative Telephone Association'
569 'name': 'GBT Communications, Inc.'
572 'name': 'Genuine Telecom'
575 'name': 'Giant Communications'
578 'name': 'Glasgow EPB'
581 'name': 'Glenwood Telecommunications'
584 'name': 'GLW Broadband Inc.'
587 'name': 'Golden West Cablevision'
590 'name': 'Grantsburg Telcom'
593 'name': 'Great Plains Communications'
596 'name': 'Gridley Cable Inc'
599 'name': 'H&B Cable Services'
602 'name': 'Haefele TV Inc.'
605 'name': 'Halstad Telephone Company'
608 'name': 'Harlan Municipal Utilities'
611 'name': 'Hart Communications'
614 'name': 'Hartelco TV'
617 'name': 'Heart of Iowa Communications Cooperative'
620 'name': 'Hickory Telephone Company'
623 'name': 'Highland Communication Services'
626 'name': 'Highland Media'
629 'name': 'Hilliary Communications'
632 'name': 'Hinton CATV Co.'
635 'name': 'HomeTel Entertainment, Inc.'
638 'name': 'Hood Canal Communications'
641 'name': 'Hope - Prescott Cable TV'
644 'name': 'Horizon Cable TV, Inc.'
647 'name': 'Horizon Chillicothe Telephone'
650 'name': 'HTC Communications Co. - IL'
653 'name': 'HTC Communications, Inc. - IA'
656 'name': 'Huxley Communications'
659 'name': 'ImOn Communications'
662 'name': 'Independence Telecommunications'
665 'name': 'Inland Networks'
668 'name': 'Innovative Cable TV St Croix'
671 'name': 'Innovative Cable TV St Thomas-St John'
674 'name': 'Inside Connect Cable'
677 'name': 'Integra Telecom'
680 'name': 'Interstate Telecommunications Coop'
683 'name': 'Irvine Cable'
686 'name': 'K2 Communications'
689 'name': 'Kalida Telephone Company, Inc.'
692 'name': 'Kalona Cooperative Telephone Company'
698 'name': 'KPU Telecommunications'
701 'name': 'Kuhn Communications, Inc.'
704 'name': 'Lakeland Communications'
710 'name': 'Laurel Highland Total Communications, Inc.'
713 'name': 'Lehigh Valley Cooperative Telephone'
716 'name': 'Limestone Cable/Bracken Cable'
728 'name': 'LocalTel Communications'
731 'name': 'Longview - Kilgore Cable TV'
734 'name': 'Lonsdale Video Ventures, LLC'
737 'name': 'Lost Nation-Elwood Telephone Co.'
740 'name': 'LPC Connect'
743 'name': 'Lumos Networks'
746 'name': 'Madison Communications'
749 'name': 'Madison County Cable Inc.'
752 'name': 'Mahaska Communication Group'
755 'name': 'Marne & Elk Horn Telephone Company'
758 'name': 'McClure Telephone Co.'
764 'name': 'Merrimac Communications Ltd.'
773 'name': 'Mid-Hudson Cable'
776 'name': 'Mid-Rivers Communications'
779 'name': 'Midstate Communications'
782 'name': 'Milford Communications'
791 'name': 'Mitchell Telecom'
797 'name': 'Mon-Cre TVE'
800 'name': 'Mountain Telephone'
803 'name': 'Mountain Village Cable'
806 'name': 'MTA Communications, LLC'
812 'name': 'MTC Technologies'
818 'name': 'MTCO Communications'
821 'name': 'Mulberry Telecommunications'
824 'name': 'Murray Electric System'
827 'name': 'MUS FiberNET'
830 'name': 'Muscatine Power & Water'
842 'name': 'Nebraska Central Telecom, Inc.'
845 'name': 'Nelsonville TV Cable'
851 'name': 'New Hope Telephone Cooperative'
857 'name': 'NineStar Connect'
863 'name': 'Nortex Communications'
866 'name': 'North Central Telephone Cooperative'
869 'name': 'Northland Communications'
872 'name': 'Northwest Communications'
875 'name': 'Norwood Light Broadband'
878 'name': 'Nsight Telservices'
884 'name': 'NTS Communications'
896 'name': 'OmniTel Communications'
899 'name': 'OneSource Communications'
902 'name': 'Opelika Power Services'
911 'name': 'OTEC Communication Company'
914 'name': 'Packerland Broadband'
917 'name': 'Panora Telco/Guthrie Center Communications'
920 'name': 'Park Region Telephone & Otter Tail Telcom'
923 'name': 'Partner Communications Cooperative'
929 'name': 'Paul Bunyan Communications'
932 'name': 'Pembroke Telephone Company'
935 'name': 'Peoples Rural Telephone Cooperative'
938 'name': 'PES Energize'
941 'name': 'Philippi Communications System'
944 'name': 'Phonoscope Cable'
947 'name': 'Pine Belt Communications, Inc.'
950 'name': 'Pine Bluff Cable TV'
953 'name': 'Pineland Telephone Cooperative'
956 'name': 'Pinpoint Communications'
959 'name': 'Pioneer Broadband'
962 'name': 'Pioneer Communications'
965 'name': 'Pioneer DTV'
968 'name': 'Plant TiftNet, Inc.'
977 'name': 'Polar Cablevision'
980 'name': 'Pottawatomie Telephone Co.'
983 'name': 'Premier Communications'
995 'name': 'Quality Cablevision'
998 'name': 'Radcliffe Telephone Company'
1001 'name': 'Rainbow Communications'
1004 'name': 'Rainier Connect'
1007 'name': 'Ralls Technologies'
1010 'name': 'RC Technologies'
1013 'name': 'Red River Communications'
1016 'name': 'Reedsburg Utility Commission'
1019 'name': 'Reliance Connects- Oregon'
1022 'name': 'Reserve Telecommunications'
1025 'name': 'Resort TV Cable'
1028 'name': 'Richland Grant Telephone Cooperative, Inc.'
1031 'name': 'River Valley Telecommunications Coop'
1034 'name': 'Rock Port Cablevision'
1040 'name': 'RTC Communication Corp'
1043 'name': 'RTC-Reservation Telephone Coop.'
1046 'name': 'RTEC Communications'
1052 'name': 'San Bruno Cable TV'
1058 'name': 'SCI Broadband-Savage Communications Inc.'
1061 'name': 'Scottsboro Electric Power Board'
1064 'name': 'Scranton Telephone Company'
1073 'name': 'Sherwood Mutual Telephone Association, Inc.'
1076 'name': 'Silver Star Communications'
1079 'name': 'Sjoberg\'s Inc.'
1085 'name': 'SkyBest TV'
1088 'name': 'Smithville Communications'
1094 'name': 'South Central Rural Telephone Cooperative'
1097 'name': 'South Holt Cablevision, Inc.'
1100 'name': 'South Slope Cooperative Communications'
1103 'name': 'Spanish Fork Community Network'
1106 'name': 'Spencer Municipal Utilities'
1109 'name': 'Spillway Communications, Inc.'
1115 'name': 'St. Maarten Cable TV'
1118 'name': 'Star Communications'
1124 'name': 'STRATA Networks'
1127 'name': 'Sumner Cable TV'
1130 'name': 'Surry TV/PCSI TV'
1133 'name': 'Swayzee Communications'
1136 'name': 'Sweetwater Cable Television Co'
1138 'weh010-talequah': {
1139 'name': 'Tahlequah Cable TV'
1145 'name': 'Tele-Media Company'
1148 'name': 'The Community Agency'
1151 'name': 'Three River'
1154 'name': 'Town & Country Technologies'
1157 'name': 'Trans-Video'
1160 'name': 'Trenton TV Cable Company'
1163 'name': 'Tri County Communications Cooperative'
1166 'name': 'TriCounty Telecom'
1169 'name': 'TrioTel Communications, Inc.'
1172 'name': 'Troy Cablevision, Inc.'
1178 'name': 'Tullahoma Utilities Board'
1181 'name': 'TV Cable of Rensselaer'
1190 'name': 'Twin Lakes'
1193 'name': 'Twin Valley'
1196 'name': 'Union Telephone Company'
1199 'name': 'United Communications - TN'
1202 'name': 'United Services'
1208 'name': 'USA Communications'
1211 'name': 'USA Communications/Shellsburg, IA'
1214 'name': 'Valley TeleCom Group'
1217 'name': 'Valley Telecommunications'
1220 'name': 'Valparaiso Broadband'
1223 'name': 'Vast Broadband'
1226 'name': 'Venture Communications Cooperative, Inc.'
1229 'name': 'Vernon Communications Co-op'
1231 'weh010-vicksburg': {
1232 'name': 'Vicksburg Video'
1235 'name': 'Vision Communications'
1238 'name': 'Volcano Vision, Inc.'
1241 'name': 'VolFirst / BLTV'
1250 'name': 'Vyve Broadband'
1253 'name': 'Wabash Mutual Telephone'
1256 'name': 'Waitsfield Cable'
1259 'name': 'Walnut Communications'
1265 'name': 'Waverly Communications Utility'
1271 'name': 'Webster-Calhoun Cooperative Telephone Association'
1274 'name': 'West Alabama TV Cable'
1277 'name': 'West Carolina Communications'
1280 'name': 'West Central Telephone Association'
1283 'name': 'West River Cooperative Telephone Company'
1286 'name': 'WesTel Systems'
1289 'name': 'Western Iowa Networks'
1292 'name': 'Whidbey Telecom'
1295 'name': 'White County Cable TV'
1304 'name': 'Wilkes Communications, Inc./RiverStreet Networks'
1307 'name': 'Wilson Communications'
1310 'name': 'Windomnet/SMBS'
1313 'name': 'Windstream Cable TV'
1316 'name': 'Winnebago Cooperative Telecom Association'
1322 'name': 'WTC Communications, Inc.'
1325 'name': 'Wyandotte Cable'
1328 'name': 'X-Stream Services'
1331 'name': 'XIT Communications'
1334 'name': 'Yelcot Communications'
1340 'name': 'Zito Media'
1344 'username_field': 'username',
1345 'password_field': 'password',
1348 'name': 'Suddenlink',
1349 'username_field': 'username',
1350 'password_field': 'password',
1355 class AdobePassIE(InfoExtractor
):
1356 _SERVICE_PROVIDER_TEMPLATE
= 'https://sp.auth.adobe.com/adobe-services/%s'
1357 _USER_AGENT
= 'Mozilla/5.0 (X11; Linux i686; rv:47.0) Gecko/20100101 Firefox/47.0'
1358 _MVPD_CACHE
= 'ap-mvpd'
1360 _DOWNLOADING_LOGIN_PAGE
= 'Downloading Provider Login Page'
1362 def _download_webpage_handle(self
, *args
, **kwargs
):
1363 headers
= self
.geo_verification_headers()
1364 headers
.update(kwargs
.get('headers', {}))
1365 kwargs
['headers'] = headers
1366 return super(AdobePassIE
, self
)._download
_webpage
_handle
(
1370 def _get_mvpd_resource(provider_id
, title
, guid
, rating
):
1371 channel
= etree
.Element('channel')
1372 channel_title
= etree
.SubElement(channel
, 'title')
1373 channel_title
.text
= provider_id
1374 item
= etree
.SubElement(channel
, 'item')
1375 resource_title
= etree
.SubElement(item
, 'title')
1376 resource_title
.text
= title
1377 resource_guid
= etree
.SubElement(item
, 'guid')
1378 resource_guid
.text
= guid
1379 resource_rating
= etree
.SubElement(item
, 'media:rating')
1380 resource_rating
.attrib
= {'scheme': 'urn:v-chip'}
1381 resource_rating
.text
= rating
1382 return '<rss version="2.0" xmlns:media="http://search.yahoo.com/mrss/">' + etree
.tostring(channel
).decode() + '</rss>'
1384 def _extract_mvpd_auth(self
, url
, video_id
, requestor_id
, resource
):
1385 def xml_text(xml_str
, tag
):
1386 return self
._search
_regex
(
1387 '<%s>(.+?)</%s>' % (tag
, tag
), xml_str
, tag
)
1389 def is_expired(token
, date_ele
):
1390 token_expires
= unified_timestamp(re
.sub(r
'[_ ]GMT', '', xml_text(token
, date_ele
)))
1391 return token_expires
and token_expires
<= int(time
.time())
1393 def post_form(form_page_res
, note
, data
={}):
1394 form_page
, urlh
= form_page_res
1395 post_url
= self
._html
_search
_regex
(r
'<form[^>]+action=(["\'])(?P
<url
>.+?
)\
1', form_page, 'post url
', group='url
')
1396 if not re.match(r'https?
://', post_url):
1397 post_url = compat_urlparse.urljoin(urlh.geturl(), post_url)
1398 form_data = self._hidden_inputs(form_page)
1399 form_data.update(data)
1400 return self._download_webpage_handle(
1401 post_url, video_id, note, data=urlencode_postdata(form_data), headers={
1402 'Content
-Type
': 'application
/x
-www
-form
-urlencoded
',
1405 def raise_mvpd_required():
1406 raise ExtractorError(
1407 'This video
is only available
for users of participating TV providers
. '
1408 'Use
--ap
-mso to specify Adobe Pass Multiple
-system operator Identifier
'
1409 'and --ap
-username
and --ap
-password
or --netrc to provide account credentials
.', expected=True)
1411 def extract_redirect_url(html, url=None, fatal=False):
1412 # TODO: eliminate code duplication with generic extractor and move
1413 # redirection code into _download_webpage_handle
1414 REDIRECT_REGEX = r'[0-9]{,2}
;\s
*(?
:URL|url
)=\'?
([^
\'"]+)'
1415 redirect_url = self._search_regex(
1416 r'(?i)<meta\s+(?=(?:[a-z-]+="[^
"]+"\s
+)*http
-equiv
="refresh")'
1417 r'(?
:[a
-z
-]+="[^"]+"\s+)*?content="%s' % REDIRECT_REGEX,
1418 html, 'meta refresh redirect
',
1419 default=NO_DEFAULT if fatal else None, fatal=fatal)
1420 if not redirect_url:
1423 redirect_url = compat_urlparse.urljoin(url, unescapeHTML(redirect_url))
1427 'ap_42
': 'anonymous
',
1428 'ap_11
': 'Linux i686
',
1429 'ap_z
': self._USER_AGENT,
1430 'User
-Agent
': self._USER_AGENT,
1433 guid = xml_text(resource, 'guid
') if '<' in resource else resource
1436 requestor_info = self._downloader.cache.load(self._MVPD_CACHE, requestor_id) or {}
1437 authn_token = requestor_info.get('authn_token
')
1438 if authn_token and is_expired(authn_token, 'simpleTokenExpires
'):
1441 # TODO add support for other TV Providers
1442 mso_id = self.get_param('ap_mso
')
1444 raise_mvpd_required()
1445 username, password = self._get_login_info('ap_username
', 'ap_password
', mso_id)
1446 if not username or not password:
1447 raise_mvpd_required()
1448 mso_info = MSO_INFO[mso_id]
1450 provider_redirect_page_res = self._download_webpage_handle(
1451 self._SERVICE_PROVIDER_TEMPLATE % 'authenticate
/saml
', video_id,
1452 'Downloading Provider Redirect Page
', query={
1455 'requestor_id
': requestor_id,
1456 'no_iframe
': 'false
',
1457 'domain_name
': 'adobe
.com
',
1458 'redirect_url
': url,
1461 if mso_id == 'Comcast_SSO
':
1462 # Comcast page flow varies by video site and whether you
1463 # are on Comcast's network
.
1464 provider_redirect_page
, urlh
= provider_redirect_page_res
1465 if 'automatically signing you in' in provider_redirect_page
:
1466 oauth_redirect_url
= self
._html
_search
_regex
(
1467 r
'window\.location\s*=\s*[\'"]([^\'"]+)',
1468 provider_redirect_page, 'oauth redirect
')
1469 self._download_webpage(
1470 oauth_redirect_url, video_id, 'Confirming auto login
')
1471 elif 'automatically signed
in with' in provider_redirect_page:
1472 # Seems like comcast is rolling up new way of automatically signing customers
1473 oauth_redirect_url = self._html_search_regex(
1474 r'continue:\s
*"(https://oauth.xfinity.com/oauth/authorize\?.+)"', provider_redirect_page,
1475 'oauth
redirect (signed
)')
1476 # Just need to process the request. No useful data comes back
1477 self._download_webpage(oauth_redirect_url, video_id, 'Confirming auto login
')
1479 if '<form name
="signin"' in provider_redirect_page:
1480 provider_login_page_res = provider_redirect_page_res
1481 elif 'http
-equiv
="refresh"' in provider_redirect_page:
1482 oauth_redirect_url = extract_redirect_url(
1483 provider_redirect_page, fatal=True)
1484 provider_login_page_res = self._download_webpage_handle(
1485 oauth_redirect_url, video_id,
1486 self._DOWNLOADING_LOGIN_PAGE)
1488 provider_login_page_res = post_form(
1489 provider_redirect_page_res,
1490 self._DOWNLOADING_LOGIN_PAGE)
1492 mvpd_confirm_page_res = post_form(
1493 provider_login_page_res, 'Logging
in', {
1494 mso_info['username_field
']: username,
1495 mso_info['password_field
']: password,
1497 mvpd_confirm_page, urlh = mvpd_confirm_page_res
1498 if '<button
class="submit" value
="Resume">Resume
</button
>' in mvpd_confirm_page:
1499 post_form(mvpd_confirm_page_res, 'Confirming Login
')
1500 elif mso_id == 'Philo
':
1501 # Philo has very unique authentication method
1502 self._download_webpage(
1503 'https
://idp
.philo
.com
/auth
/init
/login_code
', video_id, 'Requesting auth code
', data=urlencode_postdata({
1506 'send_confirm_link
': False,
1509 philo_code = compat_getpass('Type auth code you have received
[Return
]: ')
1510 self._download_webpage(
1511 'https
://idp
.philo
.com
/auth
/update
/login_code
', video_id, 'Submitting token
', data=urlencode_postdata({
1514 mvpd_confirm_page_res = self._download_webpage_handle('https
://idp
.philo
.com
/idp
/submit
', video_id, 'Confirming Philo Login
')
1515 post_form(mvpd_confirm_page_res, 'Confirming Login
')
1516 elif mso_id == 'Verizon
':
1517 # In general, if you're connecting
from a Verizon
-assigned IP
,
1518 # you will not actually pass your credentials.
1519 provider_redirect_page
, urlh
= provider_redirect_page_res
1520 # From non-Verizon IP, still gave 'Please wait', but noticed N==Y; will need to try on Verizon IP
1521 if 'Please wait ...' in provider_redirect_page
and '\'N\'== "Y"' not in provider_redirect_page
:
1522 saml_redirect_url
= self
._html
_search
_regex
(
1523 r
'self\.parent\.location=(["\'])(?P
<url
>.+?
)\
1',
1524 provider_redirect_page,
1525 'SAML Redirect URL
', group='url
')
1526 saml_login_page = self._download_webpage(
1527 saml_redirect_url, video_id,
1528 'Downloading SAML Login Page
')
1529 elif 'Verizon FiOS
- sign
in' in provider_redirect_page:
1530 # FXNetworks from non-Verizon IP
1531 saml_login_page_res = post_form(
1532 provider_redirect_page_res, 'Logging
in', {
1533 mso_info['username_field
']: username,
1534 mso_info['password_field
']: password,
1536 saml_login_page, urlh = saml_login_page_res
1537 if 'Please
try again
.' in saml_login_page:
1538 raise ExtractorError(
1539 'We
\'re sorry
, but either the User ID
or Password entered
is not correct
.')
1541 # ABC from non-Verizon IP
1542 saml_redirect_url = self._html_search_regex(
1543 r'var\surl\s
*=\s
*(["\'])(?P<url>.+?)\1',
1544 provider_redirect_page,
1545 'SAML Redirect URL', group='url')
1546 saml_redirect_url = saml_redirect_url.replace(r'\/', '/')
1547 saml_redirect_url = saml_redirect_url.replace(r'\-', '-')
1548 saml_redirect_url = saml_redirect_url.replace(r'\x26', '&')
1549 saml_login_page = self._download_webpage(
1550 saml_redirect_url, video_id,
1551 'Downloading SAML Login Page')
1552 saml_login_page, urlh = post_form(
1553 [saml_login_page, saml_redirect_url], 'Logging in', {
1554 mso_info['username_field']: username,
1555 mso_info['password_field']: password,
1557 if 'Please try again.' in saml_login_page:
1558 raise ExtractorError(
1559 'Failed to login, incorrect User ID or Password.')
1560 saml_login_url = self._search_regex(
1561 r'xmlHttp\.open\("POST
"\s*,\s*(["\'])(?P
<url
>.+?
)\
1',
1562 saml_login_page, 'SAML Login URL
', group='url
')
1563 saml_response_json = self._download_json(
1564 saml_login_url, video_id, 'Downloading SAML Response
',
1565 headers={'Content-Type': 'text/xml'})
1566 self._download_webpage(
1567 saml_response_json['targetValue
'], video_id,
1568 'Confirming Login
', data=urlencode_postdata({
1569 'SAMLResponse
': saml_response_json['SAMLResponse
'],
1570 'RelayState
': saml_response_json['RelayState
']
1572 'Content
-Type
': 'application
/x
-www
-form
-urlencoded
'
1574 elif mso_id == 'Spectrum
':
1575 # Spectrum's login
for is dynamically loaded via JS so we need to hardcode the flow
1576 # as a one-off implementation.
1577 provider_redirect_page
, urlh
= provider_redirect_page_res
1578 provider_login_page_res
= post_form(
1579 provider_redirect_page_res
, self
._DOWNLOADING
_LOGIN
_PAGE
)
1580 saml_login_page
, urlh
= provider_login_page_res
1581 relay_state
= self
._search
_regex
(
1582 r
'RelayState\s*=\s*"(?P<relay>.+?)";',
1583 saml_login_page
, 'RelayState', group
='relay')
1584 saml_request
= self
._search
_regex
(
1585 r
'SAMLRequest\s*=\s*"(?P<saml_request>.+?)";',
1586 saml_login_page
, 'SAMLRequest', group
='saml_request')
1588 mso_info
['username_field']: username
,
1589 mso_info
['password_field']: password
,
1590 'RelayState': relay_state
,
1591 'SAMLRequest': saml_request
,
1593 saml_response_json
= self
._download
_json
(
1594 'https://tveauthn.spectrum.net/tveauthentication/api/v1/manualAuth', video_id
,
1595 'Downloading SAML Response',
1596 data
=json
.dumps(login_json
).encode(),
1598 'Content-Type': 'application/json',
1599 'Accept': 'application/json',
1601 self
._download
_webpage
(
1602 saml_response_json
['SAMLRedirectUri'], video_id
,
1603 'Confirming Login', data
=urlencode_postdata({
1604 'SAMLResponse': saml_response_json
['SAMLResponse'],
1605 'RelayState': relay_state
,
1607 'Content-Type': 'application/x-www-form-urlencoded'
1609 elif mso_id
== 'slingtv':
1610 # SlingTV has a meta-refresh based authentication, but also
1611 # looks at the tab history to count the number of times the
1612 # browser has been on a page
1614 first_bookend_page
, urlh
= provider_redirect_page_res
1616 hidden_data
= self
._hidden
_inputs
(first_bookend_page
)
1617 hidden_data
['history'] = 1
1619 provider_login_page_res
= self
._download
_webpage
_handle
(
1620 urlh
.geturl(), video_id
, 'Sending first bookend',
1623 provider_association_redirect
, urlh
= post_form(
1624 provider_login_page_res
, 'Logging in', {
1625 mso_info
['username_field']: username
,
1626 mso_info
['password_field']: password
1629 provider_refresh_redirect_url
= extract_redirect_url(
1630 provider_association_redirect
, url
=urlh
.geturl())
1632 last_bookend_page
, urlh
= self
._download
_webpage
_handle
(
1633 provider_refresh_redirect_url
, video_id
,
1634 'Downloading Auth Association Redirect Page')
1635 hidden_data
= self
._hidden
_inputs
(last_bookend_page
)
1636 hidden_data
['history'] = 3
1638 mvpd_confirm_page_res
= self
._download
_webpage
_handle
(
1639 urlh
.geturl(), video_id
, 'Sending final bookend',
1642 post_form(mvpd_confirm_page_res
, 'Confirming Login')
1643 elif mso_id
== 'Suddenlink':
1644 # Suddenlink is similar to SlingTV in using a tab history count and a meta refresh,
1645 # but they also do a dynmaic redirect using javascript that has to be followed as well
1646 first_bookend_page
, urlh
= post_form(
1647 provider_redirect_page_res
, 'Pressing Continue...')
1649 hidden_data
= self
._hidden
_inputs
(first_bookend_page
)
1650 hidden_data
['history_val'] = 1
1652 provider_login_redirect_page_res
= self
._download
_webpage
_handle
(
1653 urlh
.geturl(), video_id
, 'Sending First Bookend',
1656 provider_login_redirect_page
, urlh
= provider_login_redirect_page_res
1658 # Some website partners seem to not have the extra ajaxurl redirect step, so we check if we already
1659 # have the login prompt or not
1660 if 'id="password" type="password" name="password"' in provider_login_redirect_page
:
1661 provider_login_page_res
= provider_login_redirect_page_res
1663 provider_tryauth_url
= self
._html
_search
_regex
(
1664 r
'url:\s*[\'"]([^\'"]+)', provider_login_redirect_page, 'ajaxurl
')
1665 provider_tryauth_page = self._download_webpage(
1666 provider_tryauth_url, video_id, 'Submitting TryAuth
',
1669 provider_login_page_res = self._download_webpage_handle(
1670 f'https
://authorize
.suddenlink
.net
/saml
/module
.php
/authSynacor
/login
.php?AuthState
={provider_tryauth_page}
',
1671 video_id, 'Getting Login Page
',
1674 provider_association_redirect, urlh = post_form(
1675 provider_login_page_res, 'Logging
in', {
1676 mso_info['username_field
']: username,
1677 mso_info['password_field
']: password
1680 provider_refresh_redirect_url = extract_redirect_url(
1681 provider_association_redirect, url=urlh.geturl())
1683 last_bookend_page, urlh = self._download_webpage_handle(
1684 provider_refresh_redirect_url, video_id,
1685 'Downloading Auth Association Redirect Page
')
1687 hidden_data = self._hidden_inputs(last_bookend_page)
1688 hidden_data['history_val
'] = 3
1690 mvpd_confirm_page_res = self._download_webpage_handle(
1691 urlh.geturl(), video_id, 'Sending Final Bookend
',
1694 post_form(mvpd_confirm_page_res, 'Confirming Login
')
1696 # Some providers (e.g. DIRECTV NOW) have another meta refresh
1697 # based redirect that should be followed.
1698 provider_redirect_page, urlh = provider_redirect_page_res
1699 provider_refresh_redirect_url = extract_redirect_url(
1700 provider_redirect_page, url=urlh.geturl())
1701 if provider_refresh_redirect_url:
1702 provider_redirect_page_res = self._download_webpage_handle(
1703 provider_refresh_redirect_url, video_id,
1704 'Downloading Provider Redirect
Page (meta refresh
)')
1705 provider_login_page_res = post_form(
1706 provider_redirect_page_res, self._DOWNLOADING_LOGIN_PAGE)
1708 mso_info.get('username_field
', 'username
'): username,
1709 mso_info.get('password_field
', 'password
'): password
1711 if mso_id == 'Cablevision
':
1712 form_data['_eventId_proceed
'] = ''
1713 mvpd_confirm_page_res = post_form(provider_login_page_res, 'Logging
in', form_data)
1714 if mso_id != 'Rogers
':
1715 post_form(mvpd_confirm_page_res, 'Confirming Login
')
1717 session = self._download_webpage(
1718 self._SERVICE_PROVIDER_TEMPLATE % 'session
', video_id,
1719 'Retrieving Session
', data=urlencode_postdata({
1721 'requestor_id
': requestor_id,
1722 }), headers=mvpd_headers)
1723 if '<pendingLogout
' in session:
1724 self._downloader.cache.store(self._MVPD_CACHE, requestor_id, {})
1727 authn_token = unescapeHTML(xml_text(session, 'authnToken
'))
1728 requestor_info['authn_token
'] = authn_token
1729 self._downloader.cache.store(self._MVPD_CACHE, requestor_id, requestor_info)
1731 authz_token = requestor_info.get(guid)
1732 if authz_token and is_expired(authz_token, 'simpleTokenTTL
'):
1735 authorize = self._download_webpage(
1736 self._SERVICE_PROVIDER_TEMPLATE % 'authorize
', video_id,
1737 'Retrieving Authorization Token
', data=urlencode_postdata({
1738 'resource_id
': resource,
1739 'requestor_id
': requestor_id,
1740 'authentication_token
': authn_token,
1741 'mso_id
': xml_text(authn_token, 'simpleTokenMsoID
'),
1743 }), headers=mvpd_headers)
1744 if '<pendingLogout
' in authorize:
1745 self._downloader.cache.store(self._MVPD_CACHE, requestor_id, {})
1748 if '<error
' in authorize:
1749 raise ExtractorError(xml_text(authorize, 'details
'), expected=True)
1750 authz_token = unescapeHTML(xml_text(authorize, 'authzToken
'))
1751 requestor_info[guid] = authz_token
1752 self._downloader.cache.store(self._MVPD_CACHE, requestor_id, requestor_info)
1754 mvpd_headers.update({
1755 'ap_19
': xml_text(authn_token, 'simpleSamlNameID
'),
1756 'ap_23
': xml_text(authn_token, 'simpleSamlSessionIndex
'),
1759 short_authorize = self._download_webpage(
1760 self._SERVICE_PROVIDER_TEMPLATE % 'shortAuthorize
',
1761 video_id, 'Retrieving Media Token
', data=urlencode_postdata({
1762 'authz_token
': authz_token,
1763 'requestor_id
': requestor_id,
1764 'session_guid
': xml_text(authn_token, 'simpleTokenAuthenticationGuid
'),
1765 'hashed_guid
': 'false
',
1766 }), headers=mvpd_headers)
1767 if '<pendingLogout
' in short_authorize:
1768 self._downloader.cache.store(self._MVPD_CACHE, requestor_id, {})
1771 return short_authorize