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 _MODERN_USER_AGENT
= 'Mozilla/5.0 (Windows NT 10.0; rv:131.0) Gecko/20100101 Firefox/131.0'
1359 _MVPD_CACHE
= 'ap-mvpd'
1361 _DOWNLOADING_LOGIN_PAGE
= 'Downloading Provider Login Page'
1363 def _download_webpage_handle(self
, *args
, **kwargs
):
1364 headers
= self
.geo_verification_headers()
1365 headers
.update(kwargs
.get('headers') or {})
1366 kwargs
['headers'] = headers
1367 return super()._download
_webpage
_handle
(
1371 def _get_mvpd_resource(provider_id
, title
, guid
, rating
):
1372 channel
= etree
.Element('channel')
1373 channel_title
= etree
.SubElement(channel
, 'title')
1374 channel_title
.text
= provider_id
1375 item
= etree
.SubElement(channel
, 'item')
1376 resource_title
= etree
.SubElement(item
, 'title')
1377 resource_title
.text
= title
1378 resource_guid
= etree
.SubElement(item
, 'guid')
1379 resource_guid
.text
= guid
1380 resource_rating
= etree
.SubElement(item
, 'media:rating')
1381 resource_rating
.attrib
= {'scheme': 'urn:v-chip'}
1382 resource_rating
.text
= rating
1383 return '<rss version="2.0" xmlns:media="http://search.yahoo.com/mrss/">' + etree
.tostring(channel
).decode() + '</rss>'
1385 def _extract_mvpd_auth(self
, url
, video_id
, requestor_id
, resource
):
1386 def xml_text(xml_str
, tag
):
1387 return self
._search
_regex
(
1388 f
'<{tag}>(.+?)</{tag}>', xml_str
, tag
)
1390 def is_expired(token
, date_ele
):
1391 token_expires
= unified_timestamp(re
.sub(r
'[_ ]GMT', '', xml_text(token
, date_ele
)))
1392 return token_expires
and token_expires
<= int(time
.time())
1394 def post_form(form_page_res
, note
, data
={}):
1395 form_page
, urlh
= form_page_res
1396 post_url
= self
._html
_search
_regex
(r
'<form[^>]+action=(["\'])(?P
<url
>.+?
)\
1', form_page, 'post url
', group='url
')
1397 if not re.match(r'https?
://', post_url):
1398 post_url = urllib.parse.urljoin(urlh.url, post_url)
1399 form_data = self._hidden_inputs(form_page)
1400 form_data.update(data)
1401 return self._download_webpage_handle(
1402 post_url, video_id, note, data=urlencode_postdata(form_data), headers={
1403 'Content
-Type
': 'application
/x
-www
-form
-urlencoded
',
1406 def raise_mvpd_required():
1407 raise ExtractorError(
1408 'This video
is only available
for users of participating TV providers
. '
1409 'Use
--ap
-mso to specify Adobe Pass Multiple
-system operator Identifier
'
1410 'and --ap
-username
and --ap
-password
or --netrc to provide account credentials
.', expected=True)
1412 def extract_redirect_url(html, url=None, fatal=False):
1413 # TODO: eliminate code duplication with generic extractor and move
1414 # redirection code into _download_webpage_handle
1415 REDIRECT_REGEX = r'[0-9]{,2};\s
*(?
:URL|url
)=\'?
([^
\'"]+)'
1416 redirect_url = self._search_regex(
1417 r'(?i)<meta\s+(?=(?:[a-z-]+="[^
"]+"\s
+)*http
-equiv
="refresh")'
1418 rf'(?
:[a
-z
-]+="[^"]+"\s+)*?content="{REDIRECT_REGEX}
',
1419 html, 'meta refresh redirect
',
1420 default=NO_DEFAULT if fatal else None, fatal=fatal)
1421 if not redirect_url:
1424 redirect_url = urllib.parse.urljoin(url, unescapeHTML(redirect_url))
1428 'ap_42
': 'anonymous
',
1429 'ap_11
': 'Linux i686
',
1430 'ap_z
': self._USER_AGENT,
1431 'User
-Agent
': self._USER_AGENT,
1434 guid = xml_text(resource, 'guid
') if '<' in resource else resource
1437 requestor_info = self.cache.load(self._MVPD_CACHE, requestor_id) or {}
1438 authn_token = requestor_info.get('authn_token
')
1439 if authn_token and is_expired(authn_token, 'simpleTokenExpires
'):
1442 mso_id = self.get_param('ap_mso
')
1444 username, password = self._get_login_info('ap_username
', 'ap_password
', mso_id)
1445 if not username or not password:
1446 raise_mvpd_required()
1447 mso_info = MSO_INFO[mso_id]
1449 provider_redirect_page_res = self._download_webpage_handle(
1450 self._SERVICE_PROVIDER_TEMPLATE % 'authenticate
/saml
', video_id,
1451 'Downloading Provider Redirect Page
', query={
1454 'requestor_id
': requestor_id,
1455 'no_iframe
': 'false
',
1456 'domain_name
': 'adobe
.com
',
1457 'redirect_url
': url,
1459 # yt-dlp's default user
-agent
is usually too old
for Comcast_SSO
1460 # See: https://github.com/yt-dlp/yt-dlp/issues/10848
1461 'User-Agent': self
._MODERN
_USER
_AGENT
,
1462 } if mso_id
== 'Comcast_SSO' else None)
1463 elif not self
._cookies
_passed
:
1464 raise_mvpd_required()
1468 elif mso_id
== 'Comcast_SSO':
1469 # Comcast page flow varies by video site and whether you
1470 # are on Comcast's network.
1471 provider_redirect_page
, urlh
= provider_redirect_page_res
1472 if 'automatically signing you in' in provider_redirect_page
:
1473 oauth_redirect_url
= self
._html
_search
_regex
(
1474 r
'window\.location\s*=\s*[\'"]([^\'"]+)',
1475 provider_redirect_page, 'oauth redirect
')
1476 self._download_webpage(
1477 oauth_redirect_url, video_id, 'Confirming auto login
')
1478 elif 'automatically signed
in with
' in provider_redirect_page:
1479 # Seems like comcast is rolling up new way of automatically signing customers
1480 oauth_redirect_url = self._html_search_regex(
1481 r'continue:\s
*"(https://oauth\.xfinity\.com/oauth/authorize\?.+)"', provider_redirect_page,
1482 'oauth
redirect (signed
)')
1483 # Just need to process the request. No useful data comes back
1484 self._download_webpage(oauth_redirect_url, video_id, 'Confirming auto login
')
1486 if '<form name
="signin"' in provider_redirect_page:
1487 provider_login_page_res = provider_redirect_page_res
1488 elif 'http
-equiv
="refresh"' in provider_redirect_page:
1489 oauth_redirect_url = extract_redirect_url(
1490 provider_redirect_page, fatal=True)
1491 provider_login_page_res = self._download_webpage_handle(
1492 oauth_redirect_url, video_id,
1493 self._DOWNLOADING_LOGIN_PAGE)
1495 provider_login_page_res = post_form(
1496 provider_redirect_page_res,
1497 self._DOWNLOADING_LOGIN_PAGE)
1499 mvpd_confirm_page_res = post_form(
1500 provider_login_page_res, 'Logging
in', {
1501 mso_info['username_field
']: username,
1502 mso_info['password_field
']: password,
1504 mvpd_confirm_page, urlh = mvpd_confirm_page_res
1505 if '<button
class="submit" value
="Resume">Resume
</button
>' in mvpd_confirm_page:
1506 post_form(mvpd_confirm_page_res, 'Confirming Login
')
1507 elif mso_id == 'Philo
':
1508 # Philo has very unique authentication method
1509 self._download_webpage(
1510 'https
://idp
.philo
.com
/auth
/init
/login_code
', video_id, 'Requesting auth code
', data=urlencode_postdata({
1513 'send_confirm_link
': False,
1516 philo_code = getpass.getpass('Type auth code you have received
[Return
]: ')
1517 self._download_webpage(
1518 'https
://idp
.philo
.com
/auth
/update
/login_code
', video_id, 'Submitting token
', data=urlencode_postdata({
1519 'token
': philo_code,
1521 mvpd_confirm_page_res = self._download_webpage_handle('https
://idp
.philo
.com
/idp
/submit
', video_id, 'Confirming Philo Login
')
1522 post_form(mvpd_confirm_page_res, 'Confirming Login
')
1523 elif mso_id == 'Verizon
':
1524 # In general, if you're connecting
from a Verizon
-assigned IP
,
1525 # you will not actually pass your credentials.
1526 provider_redirect_page
, urlh
= provider_redirect_page_res
1527 # From non-Verizon IP, still gave 'Please wait', but noticed N==Y; will need to try on Verizon IP
1528 if 'Please wait ...' in provider_redirect_page
and '\'N\'== "Y"' not in provider_redirect_page
:
1529 saml_redirect_url
= self
._html
_search
_regex
(
1530 r
'self\.parent\.location=(["\'])(?P
<url
>.+?
)\
1',
1531 provider_redirect_page,
1532 'SAML Redirect URL
', group='url
')
1533 saml_login_page = self._download_webpage(
1534 saml_redirect_url, video_id,
1535 'Downloading SAML Login Page
')
1536 elif 'Verizon FiOS
- sign
in' in provider_redirect_page:
1537 # FXNetworks from non-Verizon IP
1538 saml_login_page_res = post_form(
1539 provider_redirect_page_res, 'Logging
in', {
1540 mso_info['username_field
']: username,
1541 mso_info['password_field
']: password,
1543 saml_login_page, urlh = saml_login_page_res
1544 if 'Please
try again
.' in saml_login_page:
1545 raise ExtractorError(
1546 'We
\'re sorry
, but either the User ID
or Password entered
is not correct
.')
1548 # ABC from non-Verizon IP
1549 saml_redirect_url = self._html_search_regex(
1550 r'var\surl\s
*=\s
*(["\'])(?P<url>.+?)\1',
1551 provider_redirect_page,
1552 'SAML Redirect URL', group='url')
1553 saml_redirect_url = saml_redirect_url.replace(r'\/', '/')
1554 saml_redirect_url = saml_redirect_url.replace(r'\-', '-')
1555 saml_redirect_url = saml_redirect_url.replace(r'\x26', '&')
1556 saml_login_page = self._download_webpage(
1557 saml_redirect_url, video_id,
1558 'Downloading SAML Login Page')
1559 saml_login_page, urlh = post_form(
1560 [saml_login_page, saml_redirect_url], 'Logging in', {
1561 mso_info['username_field']: username,
1562 mso_info['password_field']: password,
1564 if 'Please try again.' in saml_login_page:
1565 raise ExtractorError(
1566 'Failed to login, incorrect User ID or Password.')
1567 saml_login_url = self._search_regex(
1568 r'xmlHttp\.open\("POST
"\s*,\s*(["\'])(?P
<url
>.+?
)\
1',
1569 saml_login_page, 'SAML Login URL
', group='url
')
1570 saml_response_json = self._download_json(
1571 saml_login_url, video_id, 'Downloading SAML Response
',
1572 headers={'Content
-Type
': 'text
/xml
'})
1573 self._download_webpage(
1574 saml_response_json['targetValue
'], video_id,
1575 'Confirming Login
', data=urlencode_postdata({
1576 'SAMLResponse
': saml_response_json['SAMLResponse
'],
1577 'RelayState
': saml_response_json['RelayState
'],
1579 'Content
-Type
': 'application
/x
-www
-form
-urlencoded
',
1581 elif mso_id in ('Spectrum
', 'Charter_Direct
'):
1582 # Spectrum's login
for is dynamically loaded via JS so we need to hardcode the flow
1583 # as a one-off implementation.
1584 provider_redirect_page
, urlh
= provider_redirect_page_res
1585 provider_login_page_res
= post_form(
1586 provider_redirect_page_res
, self
._DOWNLOADING
_LOGIN
_PAGE
)
1587 saml_login_page
, urlh
= provider_login_page_res
1588 relay_state
= self
._search
_regex
(
1589 r
'RelayState\s*=\s*"(?P<relay>.+?)";',
1590 saml_login_page
, 'RelayState', group
='relay')
1591 saml_request
= self
._search
_regex
(
1592 r
'SAMLRequest\s*=\s*"(?P<saml_request>.+?)";',
1593 saml_login_page
, 'SAMLRequest', group
='saml_request')
1595 mso_info
['username_field']: username
,
1596 mso_info
['password_field']: password
,
1597 'RelayState': relay_state
,
1598 'SAMLRequest': saml_request
,
1600 saml_response_json
= self
._download
_json
(
1601 'https://tveauthn.spectrum.net/tveauthentication/api/v1/manualAuth', video_id
,
1602 'Downloading SAML Response',
1603 data
=json
.dumps(login_json
).encode(),
1605 'Content-Type': 'application/json',
1606 'Accept': 'application/json',
1608 self
._download
_webpage
(
1609 saml_response_json
['SAMLRedirectUri'], video_id
,
1610 'Confirming Login', data
=urlencode_postdata({
1611 'SAMLResponse': saml_response_json
['SAMLResponse'],
1612 'RelayState': relay_state
,
1614 'Content-Type': 'application/x-www-form-urlencoded',
1616 elif mso_id
== 'slingtv':
1617 # SlingTV has a meta-refresh based authentication, but also
1618 # looks at the tab history to count the number of times the
1619 # browser has been on a page
1621 first_bookend_page
, urlh
= provider_redirect_page_res
1623 hidden_data
= self
._hidden
_inputs
(first_bookend_page
)
1624 hidden_data
['history'] = 1
1626 provider_login_page_res
= self
._download
_webpage
_handle
(
1627 urlh
.url
, video_id
, 'Sending first bookend',
1630 provider_association_redirect
, urlh
= post_form(
1631 provider_login_page_res
, 'Logging in', {
1632 mso_info
['username_field']: username
,
1633 mso_info
['password_field']: password
,
1636 provider_refresh_redirect_url
= extract_redirect_url(
1637 provider_association_redirect
, url
=urlh
.url
)
1639 last_bookend_page
, urlh
= self
._download
_webpage
_handle
(
1640 provider_refresh_redirect_url
, video_id
,
1641 'Downloading Auth Association Redirect Page')
1642 hidden_data
= self
._hidden
_inputs
(last_bookend_page
)
1643 hidden_data
['history'] = 3
1645 mvpd_confirm_page_res
= self
._download
_webpage
_handle
(
1646 urlh
.url
, video_id
, 'Sending final bookend',
1649 post_form(mvpd_confirm_page_res
, 'Confirming Login')
1650 elif mso_id
== 'Suddenlink':
1651 # Suddenlink is similar to SlingTV in using a tab history count and a meta refresh,
1652 # but they also do a dynmaic redirect using javascript that has to be followed as well
1653 first_bookend_page
, urlh
= post_form(
1654 provider_redirect_page_res
, 'Pressing Continue...')
1656 hidden_data
= self
._hidden
_inputs
(first_bookend_page
)
1657 hidden_data
['history_val'] = 1
1659 provider_login_redirect_page_res
= self
._download
_webpage
_handle
(
1660 urlh
.url
, video_id
, 'Sending First Bookend',
1663 provider_login_redirect_page
, urlh
= provider_login_redirect_page_res
1665 # Some website partners seem to not have the extra ajaxurl redirect step, so we check if we already
1666 # have the login prompt or not
1667 if 'id="password" type="password" name="password"' in provider_login_redirect_page
:
1668 provider_login_page_res
= provider_login_redirect_page_res
1670 provider_tryauth_url
= self
._html
_search
_regex
(
1671 r
'url:\s*[\'"]([^\'"]+)', provider_login_redirect_page, 'ajaxurl
')
1672 provider_tryauth_page = self._download_webpage(
1673 provider_tryauth_url, video_id, 'Submitting TryAuth
',
1676 provider_login_page_res = self._download_webpage_handle(
1677 f'https
://authorize
.suddenlink
.net
/saml
/module
.php
/authSynacor
/login
.php?AuthState
={provider_tryauth_page}
',
1678 video_id, 'Getting Login Page
',
1681 provider_association_redirect, urlh = post_form(
1682 provider_login_page_res, 'Logging
in', {
1683 mso_info['username_field
']: username,
1684 mso_info['password_field
']: password,
1687 provider_refresh_redirect_url = extract_redirect_url(
1688 provider_association_redirect, url=urlh.url)
1690 last_bookend_page, urlh = self._download_webpage_handle(
1691 provider_refresh_redirect_url, video_id,
1692 'Downloading Auth Association Redirect Page
')
1694 hidden_data = self._hidden_inputs(last_bookend_page)
1695 hidden_data['history_val
'] = 3
1697 mvpd_confirm_page_res = self._download_webpage_handle(
1698 urlh.url, video_id, 'Sending Final Bookend
',
1701 post_form(mvpd_confirm_page_res, 'Confirming Login
')
1703 # Some providers (e.g. DIRECTV NOW) have another meta refresh
1704 # based redirect that should be followed.
1705 provider_redirect_page, urlh = provider_redirect_page_res
1706 provider_refresh_redirect_url = extract_redirect_url(
1707 provider_redirect_page, url=urlh.url)
1708 if provider_refresh_redirect_url:
1709 provider_redirect_page_res = self._download_webpage_handle(
1710 provider_refresh_redirect_url, video_id,
1711 'Downloading Provider Redirect
Page (meta refresh
)')
1712 provider_login_page_res = post_form(
1713 provider_redirect_page_res, self._DOWNLOADING_LOGIN_PAGE)
1715 mso_info.get('username_field
', 'username
'): username,
1716 mso_info.get('password_field
', 'password
'): password,
1718 if mso_id in ('Cablevision
', 'AlticeOne
'):
1719 form_data['_eventId_proceed
'] = ''
1720 mvpd_confirm_page_res = post_form(provider_login_page_res, 'Logging
in', form_data)
1721 if mso_id != 'Rogers
':
1722 post_form(mvpd_confirm_page_res, 'Confirming Login
')
1725 session = self._download_webpage(
1726 self._SERVICE_PROVIDER_TEMPLATE % 'session
', video_id,
1727 'Retrieving Session
', data=urlencode_postdata({
1729 'requestor_id
': requestor_id,
1730 }), headers=mvpd_headers)
1731 except ExtractorError as e:
1732 if not mso_id and isinstance(e.cause, HTTPError) and e.cause.status == 401:
1733 raise_mvpd_required()
1735 if '<pendingLogout
' in session:
1736 self.cache.store(self._MVPD_CACHE, requestor_id, {})
1739 authn_token = unescapeHTML(xml_text(session, 'authnToken
'))
1740 requestor_info['authn_token
'] = authn_token
1741 self.cache.store(self._MVPD_CACHE, requestor_id, requestor_info)
1743 authz_token = requestor_info.get(guid)
1744 if authz_token and is_expired(authz_token, 'simpleTokenTTL
'):
1747 authorize = self._download_webpage(
1748 self._SERVICE_PROVIDER_TEMPLATE % 'authorize
', video_id,
1749 'Retrieving Authorization Token
', data=urlencode_postdata({
1750 'resource_id
': resource,
1751 'requestor_id
': requestor_id,
1752 'authentication_token
': authn_token,
1753 'mso_id
': xml_text(authn_token, 'simpleTokenMsoID
'),
1755 }), headers=mvpd_headers)
1756 if '<pendingLogout
' in authorize:
1757 self.cache.store(self._MVPD_CACHE, requestor_id, {})
1760 if '<error
' in authorize:
1761 raise ExtractorError(xml_text(authorize, 'details
'), expected=True)
1762 authz_token = unescapeHTML(xml_text(authorize, 'authzToken
'))
1763 requestor_info[guid] = authz_token
1764 self.cache.store(self._MVPD_CACHE, requestor_id, requestor_info)
1766 mvpd_headers.update({
1767 'ap_19
': xml_text(authn_token, 'simpleSamlNameID
'),
1768 'ap_23
': xml_text(authn_token, 'simpleSamlSessionIndex
'),
1771 short_authorize = self._download_webpage(
1772 self._SERVICE_PROVIDER_TEMPLATE % 'shortAuthorize
',
1773 video_id, 'Retrieving Media Token
', data=urlencode_postdata({
1774 'authz_token
': authz_token,
1775 'requestor_id
': requestor_id,
1776 'session_guid
': xml_text(authn_token, 'simpleTokenAuthenticationGuid
'),
1777 'hashed_guid
': 'false
',
1778 }), headers=mvpd_headers)
1779 if '<pendingLogout
' in short_authorize:
1780 self.cache.store(self._MVPD_CACHE, requestor_id, {})
1783 return short_authorize