5 import xml
.etree
.ElementTree
as etree
7 from .common
import InfoExtractor
24 'username_field': 'username',
25 'password_field': 'password',
28 'name': 'AT&T U-verse',
29 'username_field': 'userid',
30 'password_field': 'password',
33 'name': 'DIRECTV NOW',
34 'username_field': 'email',
35 'password_field': 'loginpassword',
39 'username_field': 'username',
40 'password_field': 'password',
44 'username_field': 'UserName',
45 'password_field': 'UserPassword',
48 'name': 'Comcast XFINITY',
49 'username_field': 'user',
50 'password_field': 'passwd',
53 'name': 'Time Warner Cable | Spectrum',
54 'username_field': 'Ecom_User_ID',
55 'password_field': 'Ecom_Password',
58 'name': 'Bright House Networks | Spectrum',
59 'username_field': 'j_username',
60 'password_field': 'j_password',
63 'name': 'Charter Spectrum',
64 'username_field': 'IDToken1',
65 'password_field': 'IDToken2',
69 'username_field': 'IDToken1',
70 'password_field': 'IDToken2',
74 'username_field': 'ident'
77 'name': 'Verizon FiOS',
78 'username_field': 'IDToken1',
79 'password_field': 'IDToken2',
82 'name': 'Optimum/Cablevision',
83 'username_field': 'j_username',
84 'password_field': 'j_password',
87 'name': '3 Rivers Communications'
90 'name': 'Access Montana'
92 'acecommunications': {
96 'name': 'Acme Communications'
99 'name': 'Adams Cable Service'
102 'name': 'Albany Mutual Telephone'
105 'name': 'Algona Municipal Utilities'
108 'name': 'All West Communications'
111 'name': 'Allen\'s Communications'
114 'name': 'Alliance Communications'
117 'name': 'ALLO Communications'
120 'name': 'Alpine Communications'
123 'name': 'American Broadband'
126 'name': 'American Broadband Missouri'
129 'name': 'American Community Networks'
132 'name': 'American Warrior Networks'
135 'name': 'Amherst Telephone/Tomorrow Valley'
141 'name': 'Arkwest Communications'
144 'name': 'Arthur Mutual Telephone Company'
150 'name': 'Ashland Home Net'
153 'name': 'Astound (now Wave)'
156 'name': 'ATC Broadband'
159 'name': 'ATC Communications'
162 'name': 'Ayersville Communications'
165 'name': 'Baldwin Lightstream'
171 'name': 'Bardstown Cable TV'
174 'name': 'Bay Country Communications'
177 'name': 'Beaver Creek Cooperative Telephone'
180 'name': 'Beaver Valley Cable'
183 'name': 'Bee Line Cable'
186 'name': 'Beehive Broadband'
192 'name': 'Bellevue Municipal Cable'
195 'name': 'Ben Lomand Connect / BLTV'
201 'name': 'Big Sandy Broadband'
204 'name': 'Bledsoe Telephone Cooperative'
207 'name': 'Blue Valley Tele-Communications'
210 'name': 'Brandenburg Telephone Co.'
213 'name': 'Bristol Tennessee Essential Services'
216 'name': 'Broadstripe'
219 'name': 'BTC Communications'
222 'name': 'BTC Vision - Nahunta'
225 'name': 'Bulloch Telephone Cooperative'
228 'name': 'Butler-Bremer Communications'
231 'name': 'C Spire SNAP'
234 'name': 'Cable Services Inc.'
237 'name': 'CableAmerica'
240 'name': 'CableSouth Media 3'
243 'name': 'Cam-Tel Company'
246 'name': 'Cameron Communications'
249 'name': 'Canby Telcom'
255 'name': 'Carnegie Cable'
264 'name': 'Catalina Broadband Solutions'
267 'name': 'CC Communications'
270 'name': 'CDE Lightband'
273 'name': 'Cedar Falls Utilities'
276 'name': 'Celect-Bloomer Telephone Area'
279 'name': 'Celect-Bruce Telephone Area'
282 'name': 'Celect-Citizens Connected Area'
285 'name': 'Celect-Elmwood/Spring Valley Area'
288 'name': 'Celect-Mosaic Telecom'
291 'name': 'Celect-West WI Telephone Area'
294 'name': 'Cellcom/Nsight Telservices'
300 'name': 'Central Scott / CSTV'
303 'name': 'Chaparral CableVision'
306 'name': 'Chariton Valley Communication Corporation, Inc.'
309 'name': 'Chatmoss Cablevision'
312 'name': 'Cherokee Communications'
315 'name': 'Chesapeake Bay Communications'
318 'name': 'Cim-Tel Cable, LLC.'
321 'name': 'Citizens Cablevision - Floyd, VA'
324 'name': 'Citizens Cablevision, Inc.'
327 'name': 'Citizens Fiber'
330 'name': 'Citizens Mutual'
333 'name': 'Citizens Telephone Corporation'
336 'name': 'City Of Monroe'
345 'name': 'Clarence Telephone and Cedar Communications'
348 'name': 'Clear Choice Communications'
351 'name': 'Click! Cable TV'
357 'name': 'CML Telephone Cooperative Association'
363 'name': 'Co-Mo Connect'
366 'name': 'Coast Communications'
369 'name': 'Coaxial Cable TV'
372 'name': 'Cobalt TV (Mid-State Community TV)'
375 'name': 'Columbia Power & Water Systems'
378 'name': 'Columbus Telephone'
381 'name': 'Communications 1 Cablevision, Inc.'
384 'name': 'Community Cable & Broadband'
387 'name': 'Community Communications Company'
393 'name': 'Complete Communication Services'
399 'name': 'ComSouth Telesys'
401 'consolidatedcable': {
402 'name': 'Consolidated'
405 'name': 'Conway Corporation'
408 'name': 'Coon Valley Telecommunications Inc'
411 'name': 'Cooperative Telephone Company'
417 'name': 'Craw-Kan Telephone'
420 'name': 'Crestview Cable Communications'
426 'name': 'Crosslake Communications'
429 'name': 'CTC - Brainerd MN'
432 'name': 'CTV-Beam - East Alabama'
435 'name': 'Cunningham Telephone & Cable'
438 'name': 'D & P Communications'
441 'name': 'Dakota Central Telecommunications'
444 'name': 'Delcambre Telephone LLC'
447 'name': 'Delta Telephone Company'
453 'name': 'Direct Communications'
456 'name': 'Doylestown Cable TV'
465 'name': 'DTC Cable (Delhi)'
468 'name': 'Dumont Telephone Company'
471 'name': 'Dunkerton Telephone Cooperative'
474 'name': 'Duo County Telecom'
477 'name': 'Eagle Communications'
480 'name': 'East Arkansas Cable TV'
483 'name': 'EATEL Video, LLC'
489 'name': 'Emery Telcom Video LLC'
492 'name': 'Empire Access'
495 'name': 'Endeavor Communications'
498 'name': 'Enhanced Telecommunications Corporation'
504 'name': 'EPB Smartnet'
507 'name': 'EPlus Broadband'
513 'name': 'Etex Communications'
516 'name': 'F&B Communications'
519 'name': 'Falcon Broadband'
522 'name': 'FamilyView CableVision'
525 'name': 'Farmers Mutual Telephone Company'
528 'name': 'Fayetteville Public Utilities'
534 'name': 'Fidelity Communications'
537 'name': 'FJ Communications'
540 'name': 'Flint River Communications'
543 'name': 'FMT - Jesup'
546 'name': 'Foothills Communications'
549 'name': 'Forsyth CableNet'
552 'name': 'Frankfort Plant Board'
555 'name': 'Franklin Telephone Company'
561 'name': 'Full Channel, Inc.'
564 'name': 'Gardonville Cooperative Telephone Association'
567 'name': 'GBT Communications, Inc.'
570 'name': 'Genuine Telecom'
573 'name': 'Giant Communications'
576 'name': 'Glasgow EPB'
579 'name': 'Glenwood Telecommunications'
582 'name': 'GLW Broadband Inc.'
585 'name': 'Golden West Cablevision'
588 'name': 'Grantsburg Telcom'
591 'name': 'Great Plains Communications'
594 'name': 'Gridley Cable Inc'
597 'name': 'H&B Cable Services'
600 'name': 'Haefele TV Inc.'
603 'name': 'Halstad Telephone Company'
606 'name': 'Harlan Municipal Utilities'
609 'name': 'Hart Communications'
612 'name': 'Hartelco TV'
615 'name': 'Heart of Iowa Communications Cooperative'
618 'name': 'Hickory Telephone Company'
621 'name': 'Highland Communication Services'
624 'name': 'Highland Media'
627 'name': 'Hilliary Communications'
630 'name': 'Hinton CATV Co.'
633 'name': 'HomeTel Entertainment, Inc.'
636 'name': 'Hood Canal Communications'
639 'name': 'Hope - Prescott Cable TV'
642 'name': 'Horizon Cable TV, Inc.'
645 'name': 'Horizon Chillicothe Telephone'
648 'name': 'HTC Communications Co. - IL'
651 'name': 'HTC Communications, Inc. - IA'
654 'name': 'Huxley Communications'
657 'name': 'ImOn Communications'
660 'name': 'Independence Telecommunications'
663 'name': 'Inland Networks'
666 'name': 'Innovative Cable TV St Croix'
669 'name': 'Innovative Cable TV St Thomas-St John'
672 'name': 'Inside Connect Cable'
675 'name': 'Integra Telecom'
678 'name': 'Interstate Telecommunications Coop'
681 'name': 'Irvine Cable'
684 'name': 'K2 Communications'
687 'name': 'Kalida Telephone Company, Inc.'
690 'name': 'Kalona Cooperative Telephone Company'
696 'name': 'KPU Telecommunications'
699 'name': 'Kuhn Communications, Inc.'
702 'name': 'Lakeland Communications'
708 'name': 'Laurel Highland Total Communications, Inc.'
711 'name': 'Lehigh Valley Cooperative Telephone'
714 'name': 'Limestone Cable/Bracken Cable'
726 'name': 'LocalTel Communications'
729 'name': 'Longview - Kilgore Cable TV'
732 'name': 'Lonsdale Video Ventures, LLC'
735 'name': 'Lost Nation-Elwood Telephone Co.'
738 'name': 'LPC Connect'
741 'name': 'Lumos Networks'
744 'name': 'Madison Communications'
747 'name': 'Madison County Cable Inc.'
750 'name': 'Mahaska Communication Group'
753 'name': 'Marne & Elk Horn Telephone Company'
756 'name': 'McClure Telephone Co.'
762 'name': 'Merrimac Communications Ltd.'
771 'name': 'Mid-Hudson Cable'
774 'name': 'Mid-Rivers Communications'
777 'name': 'Midstate Communications'
780 'name': 'Milford Communications'
789 'name': 'Mitchell Telecom'
795 'name': 'Mon-Cre TVE'
798 'name': 'Mountain Telephone'
801 'name': 'Mountain Village Cable'
804 'name': 'MTA Communications, LLC'
810 'name': 'MTC Technologies'
816 'name': 'MTCO Communications'
819 'name': 'Mulberry Telecommunications'
822 'name': 'Murray Electric System'
825 'name': 'MUS FiberNET'
828 'name': 'Muscatine Power & Water'
840 'name': 'Nebraska Central Telecom, Inc.'
843 'name': 'Nelsonville TV Cable'
849 'name': 'New Hope Telephone Cooperative'
855 'name': 'NineStar Connect'
861 'name': 'Nortex Communications'
864 'name': 'North Central Telephone Cooperative'
867 'name': 'Northland Communications'
870 'name': 'Northwest Communications'
873 'name': 'Norwood Light Broadband'
876 'name': 'Nsight Telservices'
882 'name': 'NTS Communications'
894 'name': 'OmniTel Communications'
897 'name': 'OneSource Communications'
900 'name': 'Opelika Power Services'
909 'name': 'OTEC Communication Company'
912 'name': 'Packerland Broadband'
915 'name': 'Panora Telco/Guthrie Center Communications'
918 'name': 'Park Region Telephone & Otter Tail Telcom'
921 'name': 'Partner Communications Cooperative'
927 'name': 'Paul Bunyan Communications'
930 'name': 'Pembroke Telephone Company'
933 'name': 'Peoples Rural Telephone Cooperative'
936 'name': 'PES Energize'
939 'name': 'Philippi Communications System'
942 'name': 'Phonoscope Cable'
945 'name': 'Pine Belt Communications, Inc.'
948 'name': 'Pine Bluff Cable TV'
951 'name': 'Pineland Telephone Cooperative'
954 'name': 'Pinpoint Communications'
957 'name': 'Pioneer Broadband'
960 'name': 'Pioneer Communications'
963 'name': 'Pioneer DTV'
966 'name': 'Plant TiftNet, Inc.'
975 'name': 'Polar Cablevision'
978 'name': 'Pottawatomie Telephone Co.'
981 'name': 'Premier Communications'
993 'name': 'Quality Cablevision'
996 'name': 'Radcliffe Telephone Company'
999 'name': 'Rainbow Communications'
1002 'name': 'Rainier Connect'
1005 'name': 'Ralls Technologies'
1008 'name': 'RC Technologies'
1011 'name': 'Red River Communications'
1014 'name': 'Reedsburg Utility Commission'
1017 'name': 'Reliance Connects- Oregon'
1020 'name': 'Reserve Telecommunications'
1023 'name': 'Resort TV Cable'
1026 'name': 'Richland Grant Telephone Cooperative, Inc.'
1029 'name': 'River Valley Telecommunications Coop'
1032 'name': 'Rock Port Cablevision'
1038 'name': 'RTC Communication Corp'
1041 'name': 'RTC-Reservation Telephone Coop.'
1044 'name': 'RTEC Communications'
1050 'name': 'San Bruno Cable TV'
1056 'name': 'SCI Broadband-Savage Communications Inc.'
1059 'name': 'Scottsboro Electric Power Board'
1062 'name': 'Scranton Telephone Company'
1071 'name': 'Sherwood Mutual Telephone Association, Inc.'
1074 'name': 'Silver Star Communications'
1077 'name': 'Sjoberg\'s Inc.'
1083 'name': 'SkyBest TV'
1086 'name': 'Smithville Communications'
1092 'name': 'South Central Rural Telephone Cooperative'
1095 'name': 'South Holt Cablevision, Inc.'
1098 'name': 'South Slope Cooperative Communications'
1101 'name': 'Spanish Fork Community Network'
1104 'name': 'Spencer Municipal Utilities'
1107 'name': 'Spillway Communications, Inc.'
1113 'name': 'St. Maarten Cable TV'
1116 'name': 'Star Communications'
1122 'name': 'STRATA Networks'
1125 'name': 'Sumner Cable TV'
1128 'name': 'Surry TV/PCSI TV'
1131 'name': 'Swayzee Communications'
1134 'name': 'Sweetwater Cable Television Co'
1136 'weh010-talequah': {
1137 'name': 'Tahlequah Cable TV'
1143 'name': 'Tele-Media Company'
1146 'name': 'The Community Agency'
1149 'name': 'Three River'
1152 'name': 'Town & Country Technologies'
1155 'name': 'Trans-Video'
1158 'name': 'Trenton TV Cable Company'
1161 'name': 'Tri County Communications Cooperative'
1164 'name': 'TriCounty Telecom'
1167 'name': 'TrioTel Communications, Inc.'
1170 'name': 'Troy Cablevision, Inc.'
1176 'name': 'Tullahoma Utilities Board'
1179 'name': 'TV Cable of Rensselaer'
1188 'name': 'Twin Lakes'
1191 'name': 'Twin Valley'
1194 'name': 'Union Telephone Company'
1197 'name': 'United Communications - TN'
1200 'name': 'United Services'
1206 'name': 'USA Communications'
1209 'name': 'USA Communications/Shellsburg, IA'
1212 'name': 'Valley TeleCom Group'
1215 'name': 'Valley Telecommunications'
1218 'name': 'Valparaiso Broadband'
1221 'name': 'Vast Broadband'
1224 'name': 'Venture Communications Cooperative, Inc.'
1227 'name': 'Vernon Communications Co-op'
1229 'weh010-vicksburg': {
1230 'name': 'Vicksburg Video'
1233 'name': 'Vision Communications'
1236 'name': 'Volcano Vision, Inc.'
1239 'name': 'VolFirst / BLTV'
1248 'name': 'Vyve Broadband'
1251 'name': 'Wabash Mutual Telephone'
1254 'name': 'Waitsfield Cable'
1257 'name': 'Walnut Communications'
1263 'name': 'Waverly Communications Utility'
1269 'name': 'Webster-Calhoun Cooperative Telephone Association'
1272 'name': 'West Alabama TV Cable'
1275 'name': 'West Carolina Communications'
1278 'name': 'West Central Telephone Association'
1281 'name': 'West River Cooperative Telephone Company'
1284 'name': 'WesTel Systems'
1287 'name': 'Western Iowa Networks'
1290 'name': 'Whidbey Telecom'
1293 'name': 'White County Cable TV'
1302 'name': 'Wilkes Communications, Inc./RiverStreet Networks'
1305 'name': 'Wilson Communications'
1308 'name': 'Windomnet/SMBS'
1311 'name': 'Windstream Cable TV'
1314 'name': 'Winnebago Cooperative Telecom Association'
1320 'name': 'WTC Communications, Inc.'
1323 'name': 'Wyandotte Cable'
1326 'name': 'X-Stream Services'
1329 'name': 'XIT Communications'
1332 'name': 'Yelcot Communications'
1338 'name': 'Zito Media'
1342 'username_field': 'username',
1343 'password_field': 'password',
1346 'name': 'Suddenlink',
1347 'username_field': 'username',
1348 'password_field': 'password',
1353 class AdobePassIE(InfoExtractor
):
1354 _SERVICE_PROVIDER_TEMPLATE
= 'https://sp.auth.adobe.com/adobe-services/%s'
1355 _USER_AGENT
= 'Mozilla/5.0 (X11; Linux i686; rv:47.0) Gecko/20100101 Firefox/47.0'
1356 _MVPD_CACHE
= 'ap-mvpd'
1358 _DOWNLOADING_LOGIN_PAGE
= 'Downloading Provider Login Page'
1360 def _download_webpage_handle(self
, *args
, **kwargs
):
1361 headers
= self
.geo_verification_headers()
1362 headers
.update(kwargs
.get('headers', {}))
1363 kwargs
['headers'] = headers
1364 return super(AdobePassIE
, self
)._download
_webpage
_handle
(
1368 def _get_mvpd_resource(provider_id
, title
, guid
, rating
):
1369 channel
= etree
.Element('channel')
1370 channel_title
= etree
.SubElement(channel
, 'title')
1371 channel_title
.text
= provider_id
1372 item
= etree
.SubElement(channel
, 'item')
1373 resource_title
= etree
.SubElement(item
, 'title')
1374 resource_title
.text
= title
1375 resource_guid
= etree
.SubElement(item
, 'guid')
1376 resource_guid
.text
= guid
1377 resource_rating
= etree
.SubElement(item
, 'media:rating')
1378 resource_rating
.attrib
= {'scheme': 'urn:v-chip'}
1379 resource_rating
.text
= rating
1380 return '<rss version="2.0" xmlns:media="http://search.yahoo.com/mrss/">' + etree
.tostring(channel
).decode() + '</rss>'
1382 def _extract_mvpd_auth(self
, url
, video_id
, requestor_id
, resource
):
1383 def xml_text(xml_str
, tag
):
1384 return self
._search
_regex
(
1385 '<%s>(.+?)</%s>' % (tag
, tag
), xml_str
, tag
)
1387 def is_expired(token
, date_ele
):
1388 token_expires
= unified_timestamp(re
.sub(r
'[_ ]GMT', '', xml_text(token
, date_ele
)))
1389 return token_expires
and token_expires
<= int(time
.time())
1391 def post_form(form_page_res
, note
, data
={}):
1392 form_page
, urlh
= form_page_res
1393 post_url
= self
._html
_search
_regex
(r
'<form[^>]+action=(["\'])(?P
<url
>.+?
)\
1', form_page, 'post url
', group='url
')
1394 if not re.match(r'https?
://', post_url):
1395 post_url = compat_urlparse.urljoin(urlh.geturl(), post_url)
1396 form_data = self._hidden_inputs(form_page)
1397 form_data.update(data)
1398 return self._download_webpage_handle(
1399 post_url, video_id, note, data=urlencode_postdata(form_data), headers={
1400 'Content
-Type
': 'application
/x
-www
-form
-urlencoded
',
1403 def raise_mvpd_required():
1404 raise ExtractorError(
1405 'This video
is only available
for users of participating TV providers
. '
1406 'Use
--ap
-mso to specify Adobe Pass Multiple
-system operator Identifier
'
1407 'and --ap
-username
and --ap
-password
or --netrc to provide account credentials
.', expected=True)
1409 def extract_redirect_url(html, url=None, fatal=False):
1410 # TODO: eliminate code duplication with generic extractor and move
1411 # redirection code into _download_webpage_handle
1412 REDIRECT_REGEX = r'[0-9]{,2}
;\s
*(?
:URL|url
)=\'?
([^
\'"]+)'
1413 redirect_url = self._search_regex(
1414 r'(?i)<meta\s+(?=(?:[a-z-]+="[^
"]+"\s
+)*http
-equiv
="refresh")'
1415 r'(?
:[a
-z
-]+="[^"]+"\s+)*?content="%s' % REDIRECT_REGEX,
1416 html, 'meta refresh redirect
',
1417 default=NO_DEFAULT if fatal else None, fatal=fatal)
1418 if not redirect_url:
1421 redirect_url = compat_urlparse.urljoin(url, unescapeHTML(redirect_url))
1425 'ap_42
': 'anonymous
',
1426 'ap_11
': 'Linux i686
',
1427 'ap_z
': self._USER_AGENT,
1428 'User
-Agent
': self._USER_AGENT,
1431 guid = xml_text(resource, 'guid
') if '<' in resource else resource
1434 requestor_info = self._downloader.cache.load(self._MVPD_CACHE, requestor_id) or {}
1435 authn_token = requestor_info.get('authn_token
')
1436 if authn_token and is_expired(authn_token, 'simpleTokenExpires
'):
1439 mso_id = self.get_param('ap_mso
')
1441 username, password = self._get_login_info('ap_username
', 'ap_password
', mso_id)
1442 if not username or not password:
1443 raise_mvpd_required()
1444 mso_info = MSO_INFO[mso_id]
1446 provider_redirect_page_res = self._download_webpage_handle(
1447 self._SERVICE_PROVIDER_TEMPLATE % 'authenticate
/saml
', video_id,
1448 'Downloading Provider Redirect Page
', query={
1451 'requestor_id
': requestor_id,
1452 'no_iframe
': 'false
',
1453 'domain_name
': 'adobe
.com
',
1454 'redirect_url
': url,
1456 elif not self._cookies_passed:
1457 raise_mvpd_required()
1461 elif 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
')
1718 session = self._download_webpage(
1719 self._SERVICE_PROVIDER_TEMPLATE % 'session
', video_id,
1720 'Retrieving Session
', data=urlencode_postdata({
1722 'requestor_id
': requestor_id,
1723 }), headers=mvpd_headers)
1724 except ExtractorError as e:
1725 if not mso_id and isinstance(e.cause, urllib.error.HTTPError) and e.cause.code == 401:
1726 raise_mvpd_required()
1728 if '<pendingLogout
' in session:
1729 self._downloader.cache.store(self._MVPD_CACHE, requestor_id, {})
1732 authn_token = unescapeHTML(xml_text(session, 'authnToken
'))
1733 requestor_info['authn_token
'] = authn_token
1734 self._downloader.cache.store(self._MVPD_CACHE, requestor_id, requestor_info)
1736 authz_token = requestor_info.get(guid)
1737 if authz_token and is_expired(authz_token, 'simpleTokenTTL
'):
1740 authorize = self._download_webpage(
1741 self._SERVICE_PROVIDER_TEMPLATE % 'authorize
', video_id,
1742 'Retrieving Authorization Token
', data=urlencode_postdata({
1743 'resource_id
': resource,
1744 'requestor_id
': requestor_id,
1745 'authentication_token
': authn_token,
1746 'mso_id
': xml_text(authn_token, 'simpleTokenMsoID
'),
1748 }), headers=mvpd_headers)
1749 if '<pendingLogout
' in authorize:
1750 self._downloader.cache.store(self._MVPD_CACHE, requestor_id, {})
1753 if '<error
' in authorize:
1754 raise ExtractorError(xml_text(authorize, 'details
'), expected=True)
1755 authz_token = unescapeHTML(xml_text(authorize, 'authzToken
'))
1756 requestor_info[guid] = authz_token
1757 self._downloader.cache.store(self._MVPD_CACHE, requestor_id, requestor_info)
1759 mvpd_headers.update({
1760 'ap_19
': xml_text(authn_token, 'simpleSamlNameID
'),
1761 'ap_23
': xml_text(authn_token, 'simpleSamlSessionIndex
'),
1764 short_authorize = self._download_webpage(
1765 self._SERVICE_PROVIDER_TEMPLATE % 'shortAuthorize
',
1766 video_id, 'Retrieving Media Token
', data=urlencode_postdata({
1767 'authz_token
': authz_token,
1768 'requestor_id
': requestor_id,
1769 'session_guid
': xml_text(authn_token, 'simpleTokenAuthenticationGuid
'),
1770 'hashed_guid
': 'false
',
1771 }), headers=mvpd_headers)
1772 if '<pendingLogout
' in short_authorize:
1773 self._downloader.cache.store(self._MVPD_CACHE, requestor_id, {})
1776 return short_authorize