6 import xml
.etree
.ElementTree
as etree
8 from .common
import InfoExtractor
9 from ..networking
.exceptions
import HTTPError
21 'username_field': 'username',
22 'password_field': 'password',
25 'name': 'AT&T U-verse',
26 'username_field': 'userid',
27 'password_field': 'password',
30 'name': 'DIRECTV NOW',
31 'username_field': 'email',
32 'password_field': 'loginpassword',
36 'username_field': 'username',
37 'password_field': 'password',
41 'username_field': 'UserName',
42 'password_field': 'UserPassword',
45 'name': 'Comcast XFINITY',
46 'username_field': 'user',
47 'password_field': 'passwd',
50 'name': 'Time Warner Cable | Spectrum',
51 'username_field': 'Ecom_User_ID',
52 'password_field': 'Ecom_Password',
55 'name': 'Bright House Networks | Spectrum',
56 'username_field': 'j_username',
57 'password_field': 'j_password',
60 'name': 'Charter Spectrum',
61 'username_field': 'IDToken1',
62 'password_field': 'IDToken2',
66 'username_field': 'IDToken1',
67 'password_field': 'IDToken2',
71 'username_field': 'ident',
74 'name': 'Verizon FiOS',
75 'username_field': 'IDToken1',
76 'password_field': 'IDToken2',
79 'name': 'Optimum/Cablevision',
80 'username_field': 'j_username',
81 'password_field': 'j_password',
84 'name': '3 Rivers Communications',
87 'name': 'Access Montana',
89 'acecommunications': {
93 'name': 'Acme Communications',
96 'name': 'Adams Cable Service',
99 'name': 'Albany Mutual Telephone',
102 'name': 'Algona Municipal Utilities',
105 'name': 'All West Communications',
108 'name': 'Allen\'s Communications',
111 'name': 'Alliance Communications',
114 'name': 'ALLO Communications',
117 'name': 'Alpine Communications',
120 'name': 'American Broadband',
123 'name': 'American Broadband Missouri',
126 'name': 'American Community Networks',
129 'name': 'American Warrior Networks',
132 'name': 'Amherst Telephone/Tomorrow Valley',
138 'name': 'Arkwest Communications',
141 'name': 'Arthur Mutual Telephone Company',
147 'name': 'Ashland Home Net',
150 'name': 'Astound (now Wave)',
153 'name': 'ATC Broadband',
156 'name': 'ATC Communications',
159 'name': 'Ayersville Communications',
162 'name': 'Baldwin Lightstream',
165 'name': 'Ballard TV',
168 'name': 'Bardstown Cable TV',
171 'name': 'Bay Country Communications',
174 'name': 'Beaver Creek Cooperative Telephone',
177 'name': 'Beaver Valley Cable',
180 'name': 'Bee Line Cable',
183 'name': 'Beehive Broadband',
189 'name': 'Bellevue Municipal Cable',
192 'name': 'Ben Lomand Connect / BLTV',
198 'name': 'Big Sandy Broadband',
201 'name': 'Bledsoe Telephone Cooperative',
204 'name': 'Blue Valley Tele-Communications',
207 'name': 'Brandenburg Telephone Co.',
210 'name': 'Bristol Tennessee Essential Services',
213 'name': 'Broadstripe',
216 'name': 'BTC Communications',
219 'name': 'BTC Vision - Nahunta',
222 'name': 'Bulloch Telephone Cooperative',
225 'name': 'Butler-Bremer Communications',
228 'name': 'C Spire SNAP',
231 'name': 'Cable Services Inc.',
234 'name': 'CableAmerica',
237 'name': 'CableSouth Media 3',
240 'name': 'Cam-Tel Company',
243 'name': 'Cameron Communications',
246 'name': 'Canby Telcom',
249 'name': 'CapRock Tv',
252 'name': 'Carnegie Cable',
261 'name': 'Catalina Broadband Solutions',
264 'name': 'CC Communications',
267 'name': 'CDE Lightband',
270 'name': 'Cedar Falls Utilities',
273 'name': 'Celect-Bloomer Telephone Area',
276 'name': 'Celect-Bruce Telephone Area',
279 'name': 'Celect-Citizens Connected Area',
282 'name': 'Celect-Elmwood/Spring Valley Area',
285 'name': 'Celect-Mosaic Telecom',
288 'name': 'Celect-West WI Telephone Area',
291 'name': 'Cellcom/Nsight Telservices',
297 'name': 'Central Scott / CSTV',
300 'name': 'Chaparral CableVision',
303 'name': 'Chariton Valley Communication Corporation, Inc.',
306 'name': 'Chatmoss Cablevision',
309 'name': 'Cherokee Communications',
312 'name': 'Chesapeake Bay Communications',
315 'name': 'Cim-Tel Cable, LLC.',
318 'name': 'Citizens Cablevision - Floyd, VA',
321 'name': 'Citizens Cablevision, Inc.',
324 'name': 'Citizens Fiber',
327 'name': 'Citizens Mutual',
330 'name': 'Citizens Telephone Corporation',
333 'name': 'City Of Monroe',
342 'name': 'Clarence Telephone and Cedar Communications',
345 'name': 'Clear Choice Communications',
348 'name': 'Click! Cable TV',
351 'name': 'CLICK1.NET',
354 'name': 'CML Telephone Cooperative Association',
360 'name': 'Co-Mo Connect',
363 'name': 'Coast Communications',
366 'name': 'Coaxial Cable TV',
369 'name': 'Cobalt TV (Mid-State Community TV)',
372 'name': 'Columbia Power & Water Systems',
375 'name': 'Columbus Telephone',
378 'name': 'Communications 1 Cablevision, Inc.',
381 'name': 'Community Cable & Broadband',
384 'name': 'Community Communications Company',
390 'name': 'Complete Communication Services',
396 'name': 'ComSouth Telesys',
398 'consolidatedcable': {
399 'name': 'Consolidated',
402 'name': 'Conway Corporation',
405 'name': 'Coon Valley Telecommunications Inc',
408 'name': 'Cooperative Telephone Company',
414 'name': 'Craw-Kan Telephone',
417 'name': 'Crestview Cable Communications',
423 'name': 'Crosslake Communications',
426 'name': 'CTC - Brainerd MN',
429 'name': 'CTV-Beam - East Alabama',
432 'name': 'Cunningham Telephone & Cable',
435 'name': 'D & P Communications',
438 'name': 'Dakota Central Telecommunications',
441 'name': 'Delcambre Telephone LLC',
444 'name': 'Delta Telephone Company',
447 'name': 'DiamondNet',
450 'name': 'Direct Communications',
453 'name': 'Doylestown Cable TV',
462 'name': 'DTC Cable (Delhi)',
465 'name': 'Dumont Telephone Company',
468 'name': 'Dunkerton Telephone Cooperative',
471 'name': 'Duo County Telecom',
474 'name': 'Eagle Communications',
477 'name': 'East Arkansas Cable TV',
480 'name': 'EATEL Video, LLC',
486 'name': 'Emery Telcom Video LLC',
489 'name': 'Empire Access',
492 'name': 'Endeavor Communications',
495 'name': 'Enhanced Telecommunications Corporation',
501 'name': 'EPB Smartnet',
504 'name': 'EPlus Broadband',
510 'name': 'Etex Communications',
513 'name': 'F&B Communications',
516 'name': 'Falcon Broadband',
519 'name': 'FamilyView CableVision',
522 'name': 'Farmers Mutual Telephone Company',
525 'name': 'Fayetteville Public Utilities',
531 'name': 'Fidelity Communications',
534 'name': 'FJ Communications',
537 'name': 'Flint River Communications',
540 'name': 'FMT - Jesup',
543 'name': 'Foothills Communications',
546 'name': 'Forsyth CableNet',
549 'name': 'Frankfort Plant Board',
552 'name': 'Franklin Telephone Company',
558 'name': 'Full Channel, Inc.',
561 'name': 'Gardonville Cooperative Telephone Association',
564 'name': 'GBT Communications, Inc.',
567 'name': 'Genuine Telecom',
570 'name': 'Giant Communications',
573 'name': 'Glasgow EPB',
576 'name': 'Glenwood Telecommunications',
579 'name': 'GLW Broadband Inc.',
582 'name': 'Golden West Cablevision',
585 'name': 'Grantsburg Telcom',
588 'name': 'Great Plains Communications',
591 'name': 'Gridley Cable Inc',
594 'name': 'H&B Cable Services',
597 'name': 'Haefele TV Inc.',
600 'name': 'Halstad Telephone Company',
603 'name': 'Harlan Municipal Utilities',
606 'name': 'Hart Communications',
609 'name': 'Hartelco TV',
612 'name': 'Heart of Iowa Communications Cooperative',
615 'name': 'Hickory Telephone Company',
618 'name': 'Highland Communication Services',
621 'name': 'Highland Media',
624 'name': 'Hilliary Communications',
627 'name': 'Hinton CATV Co.',
630 'name': 'HomeTel Entertainment, Inc.',
633 'name': 'Hood Canal Communications',
636 'name': 'Hope - Prescott Cable TV',
639 'name': 'Horizon Cable TV, Inc.',
642 'name': 'Horizon Chillicothe Telephone',
645 'name': 'HTC Communications Co. - IL',
648 'name': 'HTC Communications, Inc. - IA',
651 'name': 'Huxley Communications',
654 'name': 'ImOn Communications',
657 'name': 'Independence Telecommunications',
660 'name': 'Inland Networks',
663 'name': 'Innovative Cable TV St Croix',
666 'name': 'Innovative Cable TV St Thomas-St John',
669 'name': 'Inside Connect Cable',
672 'name': 'Integra Telecom',
675 'name': 'Interstate Telecommunications Coop',
678 'name': 'Irvine Cable',
681 'name': 'K2 Communications',
684 'name': 'Kalida Telephone Company, Inc.',
687 'name': 'Kalona Cooperative Telephone Company',
693 'name': 'KPU Telecommunications',
696 'name': 'Kuhn Communications, Inc.',
699 'name': 'Lakeland Communications',
705 'name': 'Laurel Highland Total Communications, Inc.',
708 'name': 'Lehigh Valley Cooperative Telephone',
711 'name': 'Limestone Cable/Bracken Cable',
717 'name': 'Litestream',
723 'name': 'LocalTel Communications',
726 'name': 'Longview - Kilgore Cable TV',
729 'name': 'Lonsdale Video Ventures, LLC',
732 'name': 'Lost Nation-Elwood Telephone Co.',
735 'name': 'LPC Connect',
738 'name': 'Lumos Networks',
741 'name': 'Madison Communications',
744 'name': 'Madison County Cable Inc.',
747 'name': 'Mahaska Communication Group',
750 'name': 'Marne & Elk Horn Telephone Company',
753 'name': 'McClure Telephone Co.',
759 'name': 'Merrimac Communications Ltd.',
768 'name': 'Mid-Hudson Cable',
771 'name': 'Mid-Rivers Communications',
774 'name': 'Midstate Communications',
777 'name': 'Milford Communications',
783 'name': 'Minford TV',
786 'name': 'Mitchell Telecom',
792 'name': 'Mon-Cre TVE',
795 'name': 'Mountain Telephone',
798 'name': 'Mountain Village Cable',
801 'name': 'MTA Communications, LLC',
807 'name': 'MTC Technologies',
813 'name': 'MTCO Communications',
816 'name': 'Mulberry Telecommunications',
819 'name': 'Murray Electric System',
822 'name': 'MUS FiberNET',
825 'name': 'Muscatine Power & Water',
828 'name': 'myEVTV.com',
837 'name': 'Nebraska Central Telecom, Inc.',
840 'name': 'Nelsonville TV Cable',
846 'name': 'New Hope Telephone Cooperative',
852 'name': 'NineStar Connect',
858 'name': 'Nortex Communications',
861 'name': 'North Central Telephone Cooperative',
864 'name': 'Northland Communications',
867 'name': 'Northwest Communications',
870 'name': 'Norwood Light Broadband',
873 'name': 'Nsight Telservices',
879 'name': 'NTS Communications',
882 'name': 'NU-Telecom',
891 'name': 'OmniTel Communications',
894 'name': 'OneSource Communications',
897 'name': 'Opelika Power Services',
906 'name': 'OTEC Communication Company',
909 'name': 'Packerland Broadband',
912 'name': 'Panora Telco/Guthrie Center Communications',
915 'name': 'Park Region Telephone & Otter Tail Telcom',
918 'name': 'Partner Communications Cooperative',
924 'name': 'Paul Bunyan Communications',
927 'name': 'Pembroke Telephone Company',
930 'name': 'Peoples Rural Telephone Cooperative',
933 'name': 'PES Energize',
936 'name': 'Philippi Communications System',
939 'name': 'Phonoscope Cable',
942 'name': 'Pine Belt Communications, Inc.',
945 'name': 'Pine Bluff Cable TV',
948 'name': 'Pineland Telephone Cooperative',
951 'name': 'Pinpoint Communications',
954 'name': 'Pioneer Broadband',
957 'name': 'Pioneer Communications',
960 'name': 'Pioneer DTV',
963 'name': 'Plant TiftNet, Inc.',
972 'name': 'Polar Cablevision',
975 'name': 'Pottawatomie Telephone Co.',
978 'name': 'Premier Communications',
990 'name': 'Quality Cablevision',
993 'name': 'Radcliffe Telephone Company',
996 'name': 'Rainbow Communications',
999 'name': 'Rainier Connect',
1002 'name': 'Ralls Technologies',
1005 'name': 'RC Technologies',
1008 'name': 'Red River Communications',
1011 'name': 'Reedsburg Utility Commission',
1014 'name': 'Reliance Connects- Oregon',
1017 'name': 'Reserve Telecommunications',
1020 'name': 'Resort TV Cable',
1023 'name': 'Richland Grant Telephone Cooperative, Inc.',
1026 'name': 'River Valley Telecommunications Coop',
1029 'name': 'Rock Port Cablevision',
1035 'name': 'RTC Communication Corp',
1038 'name': 'RTC-Reservation Telephone Coop.',
1041 'name': 'RTEC Communications',
1047 'name': 'San Bruno Cable TV',
1053 'name': 'SCI Broadband-Savage Communications Inc.',
1056 'name': 'Scottsboro Electric Power Board',
1059 'name': 'Scranton Telephone Company',
1068 'name': 'Sherwood Mutual Telephone Association, Inc.',
1071 'name': 'Silver Star Communications',
1074 'name': 'Sjoberg\'s Inc.',
1080 'name': 'SkyBest TV',
1083 'name': 'Smithville Communications',
1089 'name': 'South Central Rural Telephone Cooperative',
1092 'name': 'South Holt Cablevision, Inc.',
1095 'name': 'South Slope Cooperative Communications',
1098 'name': 'Spanish Fork Community Network',
1101 'name': 'Spencer Municipal Utilities',
1104 'name': 'Spillway Communications, Inc.',
1110 'name': 'St. Maarten Cable TV',
1113 'name': 'Star Communications',
1119 'name': 'STRATA Networks',
1122 'name': 'Sumner Cable TV',
1125 'name': 'Surry TV/PCSI TV',
1128 'name': 'Swayzee Communications',
1131 'name': 'Sweetwater Cable Television Co',
1133 'weh010-talequah': {
1134 'name': 'Tahlequah Cable TV',
1140 'name': 'Tele-Media Company',
1143 'name': 'The Community Agency',
1146 'name': 'Three River',
1149 'name': 'Town & Country Technologies',
1152 'name': 'Trans-Video',
1155 'name': 'Trenton TV Cable Company',
1158 'name': 'Tri County Communications Cooperative',
1161 'name': 'TriCounty Telecom',
1164 'name': 'TrioTel Communications, Inc.',
1167 'name': 'Troy Cablevision, Inc.',
1173 'name': 'Tullahoma Utilities Board',
1176 'name': 'TV Cable of Rensselaer',
1179 'name': 'TVC Cable',
1185 'name': 'Twin Lakes',
1188 'name': 'Twin Valley',
1191 'name': 'Union Telephone Company',
1194 'name': 'United Communications - TN',
1197 'name': 'United Services',
1203 'name': 'USA Communications',
1206 'name': 'USA Communications/Shellsburg, IA',
1209 'name': 'Valley TeleCom Group',
1212 'name': 'Valley Telecommunications',
1215 'name': 'Valparaiso Broadband',
1218 'name': 'Vast Broadband',
1221 'name': 'Venture Communications Cooperative, Inc.',
1224 'name': 'Vernon Communications Co-op',
1226 'weh010-vicksburg': {
1227 'name': 'Vicksburg Video',
1230 'name': 'Vision Communications',
1233 'name': 'Volcano Vision, Inc.',
1236 'name': 'VolFirst / BLTV',
1245 'name': 'Vyve Broadband',
1248 'name': 'Wabash Mutual Telephone',
1251 'name': 'Waitsfield Cable',
1254 'name': 'Walnut Communications',
1260 'name': 'Waverly Communications Utility',
1266 'name': 'Webster-Calhoun Cooperative Telephone Association',
1269 'name': 'West Alabama TV Cable',
1272 'name': 'West Carolina Communications',
1275 'name': 'West Central Telephone Association',
1278 'name': 'West River Cooperative Telephone Company',
1281 'name': 'WesTel Systems',
1284 'name': 'Western Iowa Networks',
1287 'name': 'Whidbey Telecom',
1290 'name': 'White County Cable TV',
1299 'name': 'Wilkes Communications, Inc./RiverStreet Networks',
1302 'name': 'Wilson Communications',
1305 'name': 'Windomnet/SMBS',
1308 'name': 'Windstream Cable TV',
1311 'name': 'Winnebago Cooperative Telecom Association',
1317 'name': 'WTC Communications, Inc.',
1320 'name': 'Wyandotte Cable',
1323 'name': 'X-Stream Services',
1326 'name': 'XIT Communications',
1329 'name': 'Yelcot Communications',
1335 'name': 'Zito Media',
1339 'username_field': 'username',
1340 'password_field': 'password',
1343 'name': 'Suddenlink',
1344 'username_field': 'username',
1345 'password_field': 'password',
1348 'name': 'Optimum TV',
1349 'username_field': 'j_username',
1350 'password_field': 'j_password',
1355 class AdobePassIE(InfoExtractor
): # XXX: Conventionally, base classes should end with BaseIE/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()._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 f
'<{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 = urllib.parse.urljoin(urlh.url, 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 rf'(?
:[a
-z
-]+="[^"]+"\s+)*?content="{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 = urllib.parse.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.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 mso_id = self.get_param('ap_mso
')
1443 username, password = self._get_login_info('ap_username
', 'ap_password
', mso_id)
1444 if not username or not password:
1445 raise_mvpd_required()
1446 mso_info = MSO_INFO[mso_id]
1448 provider_redirect_page_res = self._download_webpage_handle(
1449 self._SERVICE_PROVIDER_TEMPLATE % 'authenticate
/saml
', video_id,
1450 'Downloading Provider Redirect Page
', query={
1453 'requestor_id
': requestor_id,
1454 'no_iframe
': 'false
',
1455 'domain_name
': 'adobe
.com
',
1456 'redirect_url
': url,
1458 elif not self._cookies_passed:
1459 raise_mvpd_required()
1463 elif mso_id == 'Comcast_SSO
':
1464 # Comcast page flow varies by video site and whether you
1465 # are on Comcast's network
.
1466 provider_redirect_page
, urlh
= provider_redirect_page_res
1467 if 'automatically signing you in' in provider_redirect_page
:
1468 oauth_redirect_url
= self
._html
_search
_regex
(
1469 r
'window\.location\s*=\s*[\'"]([^\'"]+)',
1470 provider_redirect_page, 'oauth redirect
')
1471 self._download_webpage(
1472 oauth_redirect_url, video_id, 'Confirming auto login
')
1473 elif 'automatically signed
in with
' in provider_redirect_page:
1474 # Seems like comcast is rolling up new way of automatically signing customers
1475 oauth_redirect_url = self._html_search_regex(
1476 r'continue:\s
*"(https://oauth\.xfinity\.com/oauth/authorize\?.+)"', provider_redirect_page,
1477 'oauth
redirect (signed
)')
1478 # Just need to process the request. No useful data comes back
1479 self._download_webpage(oauth_redirect_url, video_id, 'Confirming auto login
')
1481 if '<form name
="signin"' in provider_redirect_page:
1482 provider_login_page_res = provider_redirect_page_res
1483 elif 'http
-equiv
="refresh"' in provider_redirect_page:
1484 oauth_redirect_url = extract_redirect_url(
1485 provider_redirect_page, fatal=True)
1486 provider_login_page_res = self._download_webpage_handle(
1487 oauth_redirect_url, video_id,
1488 self._DOWNLOADING_LOGIN_PAGE)
1490 provider_login_page_res = post_form(
1491 provider_redirect_page_res,
1492 self._DOWNLOADING_LOGIN_PAGE)
1494 mvpd_confirm_page_res = post_form(
1495 provider_login_page_res, 'Logging
in', {
1496 mso_info['username_field
']: username,
1497 mso_info['password_field
']: password,
1499 mvpd_confirm_page, urlh = mvpd_confirm_page_res
1500 if '<button
class="submit" value
="Resume">Resume
</button
>' in mvpd_confirm_page:
1501 post_form(mvpd_confirm_page_res, 'Confirming Login
')
1502 elif mso_id == 'Philo
':
1503 # Philo has very unique authentication method
1504 self._download_webpage(
1505 'https
://idp
.philo
.com
/auth
/init
/login_code
', video_id, 'Requesting auth code
', data=urlencode_postdata({
1508 'send_confirm_link
': False,
1511 philo_code = getpass.getpass('Type auth code you have received
[Return
]: ')
1512 self._download_webpage(
1513 'https
://idp
.philo
.com
/auth
/update
/login_code
', video_id, 'Submitting token
', data=urlencode_postdata({
1514 'token
': philo_code,
1516 mvpd_confirm_page_res = self._download_webpage_handle('https
://idp
.philo
.com
/idp
/submit
', video_id, 'Confirming Philo Login
')
1517 post_form(mvpd_confirm_page_res, 'Confirming Login
')
1518 elif mso_id == 'Verizon
':
1519 # In general, if you're connecting
from a Verizon
-assigned IP
,
1520 # you will not actually pass your credentials.
1521 provider_redirect_page
, urlh
= provider_redirect_page_res
1522 # From non-Verizon IP, still gave 'Please wait', but noticed N==Y; will need to try on Verizon IP
1523 if 'Please wait ...' in provider_redirect_page
and '\'N\'== "Y"' not in provider_redirect_page
:
1524 saml_redirect_url
= self
._html
_search
_regex
(
1525 r
'self\.parent\.location=(["\'])(?P
<url
>.+?
)\
1',
1526 provider_redirect_page,
1527 'SAML Redirect URL
', group='url
')
1528 saml_login_page = self._download_webpage(
1529 saml_redirect_url, video_id,
1530 'Downloading SAML Login Page
')
1531 elif 'Verizon FiOS
- sign
in' in provider_redirect_page:
1532 # FXNetworks from non-Verizon IP
1533 saml_login_page_res = post_form(
1534 provider_redirect_page_res, 'Logging
in', {
1535 mso_info['username_field
']: username,
1536 mso_info['password_field
']: password,
1538 saml_login_page, urlh = saml_login_page_res
1539 if 'Please
try again
.' in saml_login_page:
1540 raise ExtractorError(
1541 'We
\'re sorry
, but either the User ID
or Password entered
is not correct
.')
1543 # ABC from non-Verizon IP
1544 saml_redirect_url = self._html_search_regex(
1545 r'var\surl\s
*=\s
*(["\'])(?P<url>.+?)\1',
1546 provider_redirect_page,
1547 'SAML Redirect URL', group='url')
1548 saml_redirect_url = saml_redirect_url.replace(r'\/', '/')
1549 saml_redirect_url = saml_redirect_url.replace(r'\-', '-')
1550 saml_redirect_url = saml_redirect_url.replace(r'\x26', '&')
1551 saml_login_page = self._download_webpage(
1552 saml_redirect_url, video_id,
1553 'Downloading SAML Login Page')
1554 saml_login_page, urlh = post_form(
1555 [saml_login_page, saml_redirect_url], 'Logging in', {
1556 mso_info['username_field']: username,
1557 mso_info['password_field']: password,
1559 if 'Please try again.' in saml_login_page:
1560 raise ExtractorError(
1561 'Failed to login, incorrect User ID or Password.')
1562 saml_login_url = self._search_regex(
1563 r'xmlHttp\.open\("POST
"\s*,\s*(["\'])(?P
<url
>.+?
)\
1',
1564 saml_login_page, 'SAML Login URL
', group='url
')
1565 saml_response_json = self._download_json(
1566 saml_login_url, video_id, 'Downloading SAML Response
',
1567 headers={'Content
-Type
': 'text
/xml
'})
1568 self._download_webpage(
1569 saml_response_json['targetValue
'], video_id,
1570 'Confirming Login
', data=urlencode_postdata({
1571 'SAMLResponse
': saml_response_json['SAMLResponse
'],
1572 'RelayState
': saml_response_json['RelayState
'],
1574 'Content
-Type
': 'application
/x
-www
-form
-urlencoded
',
1576 elif mso_id in ('Spectrum
', 'Charter_Direct
'):
1577 # Spectrum's login
for is dynamically loaded via JS so we need to hardcode the flow
1578 # as a one-off implementation.
1579 provider_redirect_page
, urlh
= provider_redirect_page_res
1580 provider_login_page_res
= post_form(
1581 provider_redirect_page_res
, self
._DOWNLOADING
_LOGIN
_PAGE
)
1582 saml_login_page
, urlh
= provider_login_page_res
1583 relay_state
= self
._search
_regex
(
1584 r
'RelayState\s*=\s*"(?P<relay>.+?)";',
1585 saml_login_page
, 'RelayState', group
='relay')
1586 saml_request
= self
._search
_regex
(
1587 r
'SAMLRequest\s*=\s*"(?P<saml_request>.+?)";',
1588 saml_login_page
, 'SAMLRequest', group
='saml_request')
1590 mso_info
['username_field']: username
,
1591 mso_info
['password_field']: password
,
1592 'RelayState': relay_state
,
1593 'SAMLRequest': saml_request
,
1595 saml_response_json
= self
._download
_json
(
1596 'https://tveauthn.spectrum.net/tveauthentication/api/v1/manualAuth', video_id
,
1597 'Downloading SAML Response',
1598 data
=json
.dumps(login_json
).encode(),
1600 'Content-Type': 'application/json',
1601 'Accept': 'application/json',
1603 self
._download
_webpage
(
1604 saml_response_json
['SAMLRedirectUri'], video_id
,
1605 'Confirming Login', data
=urlencode_postdata({
1606 'SAMLResponse': saml_response_json
['SAMLResponse'],
1607 'RelayState': relay_state
,
1609 'Content-Type': 'application/x-www-form-urlencoded',
1611 elif mso_id
== 'slingtv':
1612 # SlingTV has a meta-refresh based authentication, but also
1613 # looks at the tab history to count the number of times the
1614 # browser has been on a page
1616 first_bookend_page
, urlh
= provider_redirect_page_res
1618 hidden_data
= self
._hidden
_inputs
(first_bookend_page
)
1619 hidden_data
['history'] = 1
1621 provider_login_page_res
= self
._download
_webpage
_handle
(
1622 urlh
.url
, video_id
, 'Sending first bookend',
1625 provider_association_redirect
, urlh
= post_form(
1626 provider_login_page_res
, 'Logging in', {
1627 mso_info
['username_field']: username
,
1628 mso_info
['password_field']: password
,
1631 provider_refresh_redirect_url
= extract_redirect_url(
1632 provider_association_redirect
, url
=urlh
.url
)
1634 last_bookend_page
, urlh
= self
._download
_webpage
_handle
(
1635 provider_refresh_redirect_url
, video_id
,
1636 'Downloading Auth Association Redirect Page')
1637 hidden_data
= self
._hidden
_inputs
(last_bookend_page
)
1638 hidden_data
['history'] = 3
1640 mvpd_confirm_page_res
= self
._download
_webpage
_handle
(
1641 urlh
.url
, video_id
, 'Sending final bookend',
1644 post_form(mvpd_confirm_page_res
, 'Confirming Login')
1645 elif mso_id
== 'Suddenlink':
1646 # Suddenlink is similar to SlingTV in using a tab history count and a meta refresh,
1647 # but they also do a dynmaic redirect using javascript that has to be followed as well
1648 first_bookend_page
, urlh
= post_form(
1649 provider_redirect_page_res
, 'Pressing Continue...')
1651 hidden_data
= self
._hidden
_inputs
(first_bookend_page
)
1652 hidden_data
['history_val'] = 1
1654 provider_login_redirect_page_res
= self
._download
_webpage
_handle
(
1655 urlh
.url
, video_id
, 'Sending First Bookend',
1658 provider_login_redirect_page
, urlh
= provider_login_redirect_page_res
1660 # Some website partners seem to not have the extra ajaxurl redirect step, so we check if we already
1661 # have the login prompt or not
1662 if 'id="password" type="password" name="password"' in provider_login_redirect_page
:
1663 provider_login_page_res
= provider_login_redirect_page_res
1665 provider_tryauth_url
= self
._html
_search
_regex
(
1666 r
'url:\s*[\'"]([^\'"]+)', provider_login_redirect_page, 'ajaxurl
')
1667 provider_tryauth_page = self._download_webpage(
1668 provider_tryauth_url, video_id, 'Submitting TryAuth
',
1671 provider_login_page_res = self._download_webpage_handle(
1672 f'https
://authorize
.suddenlink
.net
/saml
/module
.php
/authSynacor
/login
.php?AuthState
={provider_tryauth_page}
',
1673 video_id, 'Getting Login Page
',
1676 provider_association_redirect, urlh = post_form(
1677 provider_login_page_res, 'Logging
in', {
1678 mso_info['username_field
']: username,
1679 mso_info['password_field
']: password,
1682 provider_refresh_redirect_url = extract_redirect_url(
1683 provider_association_redirect, url=urlh.url)
1685 last_bookend_page, urlh = self._download_webpage_handle(
1686 provider_refresh_redirect_url, video_id,
1687 'Downloading Auth Association Redirect Page
')
1689 hidden_data = self._hidden_inputs(last_bookend_page)
1690 hidden_data['history_val
'] = 3
1692 mvpd_confirm_page_res = self._download_webpage_handle(
1693 urlh.url, video_id, 'Sending Final Bookend
',
1696 post_form(mvpd_confirm_page_res, 'Confirming Login
')
1698 # Some providers (e.g. DIRECTV NOW) have another meta refresh
1699 # based redirect that should be followed.
1700 provider_redirect_page, urlh = provider_redirect_page_res
1701 provider_refresh_redirect_url = extract_redirect_url(
1702 provider_redirect_page, url=urlh.url)
1703 if provider_refresh_redirect_url:
1704 provider_redirect_page_res = self._download_webpage_handle(
1705 provider_refresh_redirect_url, video_id,
1706 'Downloading Provider Redirect
Page (meta refresh
)')
1707 provider_login_page_res = post_form(
1708 provider_redirect_page_res, self._DOWNLOADING_LOGIN_PAGE)
1710 mso_info.get('username_field
', 'username
'): username,
1711 mso_info.get('password_field
', 'password
'): password,
1713 if mso_id in ('Cablevision
', 'AlticeOne
'):
1714 form_data['_eventId_proceed
'] = ''
1715 mvpd_confirm_page_res = post_form(provider_login_page_res, 'Logging
in', form_data)
1716 if mso_id != 'Rogers
':
1717 post_form(mvpd_confirm_page_res, 'Confirming Login
')
1720 session = self._download_webpage(
1721 self._SERVICE_PROVIDER_TEMPLATE % 'session
', video_id,
1722 'Retrieving Session
', data=urlencode_postdata({
1724 'requestor_id
': requestor_id,
1725 }), headers=mvpd_headers)
1726 except ExtractorError as e:
1727 if not mso_id and isinstance(e.cause, HTTPError) and e.cause.status == 401:
1728 raise_mvpd_required()
1730 if '<pendingLogout
' in session:
1731 self.cache.store(self._MVPD_CACHE, requestor_id, {})
1734 authn_token = unescapeHTML(xml_text(session, 'authnToken
'))
1735 requestor_info['authn_token
'] = authn_token
1736 self.cache.store(self._MVPD_CACHE, requestor_id, requestor_info)
1738 authz_token = requestor_info.get(guid)
1739 if authz_token and is_expired(authz_token, 'simpleTokenTTL
'):
1742 authorize = self._download_webpage(
1743 self._SERVICE_PROVIDER_TEMPLATE % 'authorize
', video_id,
1744 'Retrieving Authorization Token
', data=urlencode_postdata({
1745 'resource_id
': resource,
1746 'requestor_id
': requestor_id,
1747 'authentication_token
': authn_token,
1748 'mso_id
': xml_text(authn_token, 'simpleTokenMsoID
'),
1750 }), headers=mvpd_headers)
1751 if '<pendingLogout
' in authorize:
1752 self.cache.store(self._MVPD_CACHE, requestor_id, {})
1755 if '<error
' in authorize:
1756 raise ExtractorError(xml_text(authorize, 'details
'), expected=True)
1757 authz_token = unescapeHTML(xml_text(authorize, 'authzToken
'))
1758 requestor_info[guid] = authz_token
1759 self.cache.store(self._MVPD_CACHE, requestor_id, requestor_info)
1761 mvpd_headers.update({
1762 'ap_19
': xml_text(authn_token, 'simpleSamlNameID
'),
1763 'ap_23
': xml_text(authn_token, 'simpleSamlSessionIndex
'),
1766 short_authorize = self._download_webpage(
1767 self._SERVICE_PROVIDER_TEMPLATE % 'shortAuthorize
',
1768 video_id, 'Retrieving Media Token
', data=urlencode_postdata({
1769 'authz_token
': authz_token,
1770 'requestor_id
': requestor_id,
1771 'session_guid
': xml_text(authn_token, 'simpleTokenAuthenticationGuid
'),
1772 'hashed_guid
': 'false
',
1773 }), headers=mvpd_headers)
1774 if '<pendingLogout
' in short_authorize:
1775 self.cache.store(self._MVPD_CACHE, requestor_id, {})
1778 return short_authorize