2 from __future__
import unicode_literals
6 import xml
.etree
.ElementTree
as etree
8 from .common
import InfoExtractor
9 from ..compat
import compat_urlparse
21 'username_field': 'username',
22 'password_field': 'password',
26 'username_field': 'UserName',
27 'password_field': 'UserPassword',
30 'name': 'Comcast XFINITY',
31 'username_field': 'user',
32 'password_field': 'passwd',
35 'name': 'Time Warner Cable | Spectrum',
36 'username_field': 'Ecom_User_ID',
37 'password_field': 'Ecom_Password',
40 'name': 'Charter Spectrum',
41 'username_field': 'IDToken1',
42 'password_field': 'IDToken2',
45 'name': 'Verizon FiOS',
46 'username_field': 'IDToken1',
47 'password_field': 'IDToken2',
50 'name': '3 Rivers Communications'
53 'name': 'Access Montana'
55 'acecommunications': {
59 'name': 'Acme Communications'
62 'name': 'Adams Cable Service'
65 'name': 'Albany Mutual Telephone'
68 'name': 'Algona Municipal Utilities'
71 'name': 'All West Communications'
74 'name': 'Allen\'s Communications'
77 'name': 'Alliance Communications'
80 'name': 'ALLO Communications'
83 'name': 'Alpine Communications'
86 'name': 'American Broadband'
89 'name': 'American Broadband Missouri'
92 'name': 'American Community Networks'
95 'name': 'American Warrior Networks'
98 'name': 'Amherst Telephone/Tomorrow Valley'
104 'name': 'Arkwest Communications'
107 'name': 'Arthur Mutual Telephone Company'
113 'name': 'Ashland Home Net'
116 'name': 'Astound (now Wave)'
119 'name': 'ATC Broadband'
122 'name': 'ATC Communications'
125 'name': 'Ayersville Communications'
128 'name': 'Baldwin Lightstream'
134 'name': 'Bardstown Cable TV'
137 'name': 'Bay Country Communications'
140 'name': 'Beaver Creek Cooperative Telephone'
143 'name': 'Beaver Valley Cable'
146 'name': 'Bee Line Cable'
149 'name': 'Beehive Broadband'
155 'name': 'Bellevue Municipal Cable'
158 'name': 'Ben Lomand Connect / BLTV'
164 'name': 'Big Sandy Broadband'
167 'name': 'Bledsoe Telephone Cooperative'
170 'name': 'Blue Valley Tele-Communications'
173 'name': 'Brandenburg Telephone Co.'
176 'name': 'Bristol Tennessee Essential Services'
179 'name': 'Broadstripe'
182 'name': 'BTC Communications'
185 'name': 'BTC Vision - Nahunta'
188 'name': 'Bulloch Telephone Cooperative'
191 'name': 'Butler-Bremer Communications'
194 'name': 'C Spire SNAP'
197 'name': 'Cable Services Inc.'
200 'name': 'CableAmerica'
203 'name': 'CableSouth Media 3'
206 'name': 'Cam-Tel Company'
209 'name': 'Cameron Communications'
212 'name': 'Canby Telcom'
218 'name': 'Carnegie Cable'
227 'name': 'Catalina Broadband Solutions'
230 'name': 'CC Communications'
233 'name': 'CDE Lightband'
236 'name': 'Cedar Falls Utilities'
239 'name': 'Celect-Bloomer Telephone Area'
242 'name': 'Celect-Bruce Telephone Area'
245 'name': 'Celect-Citizens Connected Area'
248 'name': 'Celect-Elmwood/Spring Valley Area'
251 'name': 'Celect-Mosaic Telecom'
254 'name': 'Celect-West WI Telephone Area'
257 'name': 'Cellcom/Nsight Telservices'
263 'name': 'Central Scott / CSTV'
266 'name': 'Chaparral CableVision'
269 'name': 'Chariton Valley Communication Corporation, Inc.'
272 'name': 'Chatmoss Cablevision'
275 'name': 'Cherokee Communications'
278 'name': 'Chesapeake Bay Communications'
281 'name': 'Cim-Tel Cable, LLC.'
284 'name': 'Citizens Cablevision - Floyd, VA'
287 'name': 'Citizens Cablevision, Inc.'
290 'name': 'Citizens Fiber'
293 'name': 'Citizens Mutual'
296 'name': 'Citizens Telephone Corporation'
299 'name': 'City Of Monroe'
308 'name': 'Clarence Telephone and Cedar Communications'
311 'name': 'Clear Choice Communications'
314 'name': 'Click! Cable TV'
320 'name': 'CML Telephone Cooperative Association'
326 'name': 'Co-Mo Connect'
329 'name': 'Coast Communications'
332 'name': 'Coaxial Cable TV'
335 'name': 'Cobalt TV (Mid-State Community TV)'
338 'name': 'Columbia Power & Water Systems'
341 'name': 'Columbus Telephone'
344 'name': 'Communications 1 Cablevision, Inc.'
347 'name': 'Community Cable & Broadband'
350 'name': 'Community Communications Company'
356 'name': 'Complete Communication Services'
362 'name': 'ComSouth Telesys'
364 'consolidatedcable': {
365 'name': 'Consolidated'
368 'name': 'Conway Corporation'
371 'name': 'Coon Valley Telecommunications Inc'
374 'name': 'Cooperative Telephone Company'
380 'name': 'Craw-Kan Telephone'
383 'name': 'Crestview Cable Communications'
389 'name': 'Crosslake Communications'
392 'name': 'CTC - Brainerd MN'
395 'name': 'CTV-Beam - East Alabama'
398 'name': 'Cunningham Telephone & Cable'
401 'name': 'D & P Communications'
404 'name': 'Dakota Central Telecommunications'
407 'name': 'Delcambre Telephone LLC'
410 'name': 'Delta Telephone Company'
416 'name': 'Direct Communications'
419 'name': 'Doylestown Cable TV'
428 'name': 'DTC Cable (Delhi)'
431 'name': 'Dumont Telephone Company'
434 'name': 'Dunkerton Telephone Cooperative'
437 'name': 'Duo County Telecom'
440 'name': 'Eagle Communications'
443 'name': 'East Arkansas Cable TV'
446 'name': 'EATEL Video, LLC'
452 'name': 'Emery Telcom Video LLC'
455 'name': 'Empire Access'
458 'name': 'Endeavor Communications'
461 'name': 'Enhanced Telecommunications Corporation'
467 'name': 'EPB Smartnet'
470 'name': 'EPlus Broadband'
476 'name': 'Etex Communications'
479 'name': 'F&B Communications'
482 'name': 'Falcon Broadband'
485 'name': 'FamilyView CableVision'
488 'name': 'Farmers Mutual Telephone Company'
491 'name': 'Fayetteville Public Utilities'
497 'name': 'Fidelity Communications'
500 'name': 'FJ Communications'
503 'name': 'Flint River Communications'
506 'name': 'FMT - Jesup'
509 'name': 'Foothills Communications'
512 'name': 'Forsyth CableNet'
515 'name': 'Frankfort Plant Board'
518 'name': 'Franklin Telephone Company'
524 'name': 'Full Channel, Inc.'
527 'name': 'Gardonville Cooperative Telephone Association'
530 'name': 'GBT Communications, Inc.'
533 'name': 'Genuine Telecom'
536 'name': 'Giant Communications'
539 'name': 'Glasgow EPB'
542 'name': 'Glenwood Telecommunications'
545 'name': 'GLW Broadband Inc.'
548 'name': 'Golden West Cablevision'
551 'name': 'Grantsburg Telcom'
554 'name': 'Great Plains Communications'
557 'name': 'Gridley Cable Inc'
560 'name': 'H&B Cable Services'
563 'name': 'Haefele TV Inc.'
566 'name': 'Halstad Telephone Company'
569 'name': 'Harlan Municipal Utilities'
572 'name': 'Hart Communications'
575 'name': 'Hartelco TV'
578 'name': 'Heart of Iowa Communications Cooperative'
581 'name': 'Hickory Telephone Company'
584 'name': 'Highland Communication Services'
587 'name': 'Highland Media'
590 'name': 'Hilliary Communications'
593 'name': 'Hinton CATV Co.'
596 'name': 'HomeTel Entertainment, Inc.'
599 'name': 'Hood Canal Communications'
602 'name': 'Hope - Prescott Cable TV'
605 'name': 'Horizon Cable TV, Inc.'
608 'name': 'Horizon Chillicothe Telephone'
611 'name': 'HTC Communications Co. - IL'
614 'name': 'HTC Communications, Inc. - IA'
617 'name': 'Huxley Communications'
620 'name': 'ImOn Communications'
623 'name': 'Independence Telecommunications'
626 'name': 'Inland Networks'
629 'name': 'Innovative Cable TV St Croix'
632 'name': 'Innovative Cable TV St Thomas-St John'
635 'name': 'Inside Connect Cable'
638 'name': 'Integra Telecom'
641 'name': 'Interstate Telecommunications Coop'
644 'name': 'Irvine Cable'
647 'name': 'K2 Communications'
650 'name': 'Kalida Telephone Company, Inc.'
653 'name': 'Kalona Cooperative Telephone Company'
659 'name': 'KPU Telecommunications'
662 'name': 'Kuhn Communications, Inc.'
665 'name': 'Lakeland Communications'
671 'name': 'Laurel Highland Total Communications, Inc.'
674 'name': 'Lehigh Valley Cooperative Telephone'
677 'name': 'Limestone Cable/Bracken Cable'
689 'name': 'LocalTel Communications'
692 'name': 'Longview - Kilgore Cable TV'
695 'name': 'Lonsdale Video Ventures, LLC'
698 'name': 'Lost Nation-Elwood Telephone Co.'
701 'name': 'LPC Connect'
704 'name': 'Lumos Networks'
707 'name': 'Madison Communications'
710 'name': 'Madison County Cable Inc.'
713 'name': 'Mahaska Communication Group'
716 'name': 'Marne & Elk Horn Telephone Company'
719 'name': 'McClure Telephone Co.'
725 'name': 'Merrimac Communications Ltd.'
734 'name': 'Mid-Hudson Cable'
737 'name': 'Mid-Rivers Communications'
740 'name': 'Midstate Communications'
743 'name': 'Milford Communications'
752 'name': 'Mitchell Telecom'
758 'name': 'Mon-Cre TVE'
761 'name': 'Mountain Telephone'
764 'name': 'Mountain Village Cable'
767 'name': 'MTA Communications, LLC'
773 'name': 'MTC Technologies'
779 'name': 'MTCO Communications'
782 'name': 'Mulberry Telecommunications'
785 'name': 'Murray Electric System'
788 'name': 'MUS FiberNET'
791 'name': 'Muscatine Power & Water'
803 'name': 'Nebraska Central Telecom, Inc.'
806 'name': 'Nelsonville TV Cable'
812 'name': 'New Hope Telephone Cooperative'
818 'name': 'NineStar Connect'
824 'name': 'Nortex Communications'
827 'name': 'North Central Telephone Cooperative'
830 'name': 'Northland Communications'
833 'name': 'Northwest Communications'
836 'name': 'Norwood Light Broadband'
839 'name': 'Nsight Telservices'
845 'name': 'NTS Communications'
857 'name': 'OmniTel Communications'
860 'name': 'OneSource Communications'
863 'name': 'Opelika Power Services'
872 'name': 'OTEC Communication Company'
875 'name': 'Packerland Broadband'
878 'name': 'Panora Telco/Guthrie Center Communications'
881 'name': 'Park Region Telephone & Otter Tail Telcom'
884 'name': 'Partner Communications Cooperative'
890 'name': 'Paul Bunyan Communications'
893 'name': 'Pembroke Telephone Company'
896 'name': 'Peoples Rural Telephone Cooperative'
899 'name': 'PES Energize'
902 'name': 'Philippi Communications System'
905 'name': 'Phonoscope Cable'
908 'name': 'Pine Belt Communications, Inc.'
911 'name': 'Pine Bluff Cable TV'
914 'name': 'Pineland Telephone Cooperative'
917 'name': 'Pinpoint Communications'
920 'name': 'Pioneer Broadband'
923 'name': 'Pioneer Communications'
926 'name': 'Pioneer DTV'
929 'name': 'Plant TiftNet, Inc.'
938 'name': 'Polar Cablevision'
941 'name': 'Pottawatomie Telephone Co.'
944 'name': 'Premier Communications'
956 'name': 'Quality Cablevision'
959 'name': 'Radcliffe Telephone Company'
962 'name': 'Rainbow Communications'
965 'name': 'Rainier Connect'
968 'name': 'Ralls Technologies'
971 'name': 'RC Technologies'
974 'name': 'Red River Communications'
977 'name': 'Reedsburg Utility Commission'
980 'name': 'Reliance Connects- Oregon'
983 'name': 'Reserve Telecommunications'
986 'name': 'Resort TV Cable'
989 'name': 'Richland Grant Telephone Cooperative, Inc.'
992 'name': 'River Valley Telecommunications Coop'
995 'name': 'Rock Port Cablevision'
1001 'name': 'RTC Communication Corp'
1004 'name': 'RTC-Reservation Telephone Coop.'
1007 'name': 'RTEC Communications'
1013 'name': 'San Bruno Cable TV'
1019 'name': 'SCI Broadband-Savage Communications Inc.'
1022 'name': 'Scottsboro Electric Power Board'
1025 'name': 'Scranton Telephone Company'
1034 'name': 'Sherwood Mutual Telephone Association, Inc.'
1037 'name': 'Silver Star Communications'
1040 'name': 'Sjoberg\'s Inc.'
1046 'name': 'SkyBest TV'
1049 'name': 'Smithville Communications'
1055 'name': 'South Central Rural Telephone Cooperative'
1058 'name': 'South Holt Cablevision, Inc.'
1061 'name': 'South Slope Cooperative Communications'
1064 'name': 'Spanish Fork Community Network'
1067 'name': 'Spencer Municipal Utilities'
1070 'name': 'Spillway Communications, Inc.'
1076 'name': 'St. Maarten Cable TV'
1079 'name': 'Star Communications'
1085 'name': 'STRATA Networks'
1088 'name': 'Sumner Cable TV'
1091 'name': 'Surry TV/PCSI TV'
1094 'name': 'Swayzee Communications'
1097 'name': 'Sweetwater Cable Television Co'
1099 'weh010-talequah': {
1100 'name': 'Tahlequah Cable TV'
1106 'name': 'Tele-Media Company'
1109 'name': 'The Community Agency'
1112 'name': 'Three River'
1115 'name': 'Town & Country Technologies'
1118 'name': 'Trans-Video'
1121 'name': 'Trenton TV Cable Company'
1124 'name': 'Tri County Communications Cooperative'
1127 'name': 'TriCounty Telecom'
1130 'name': 'TrioTel Communications, Inc.'
1133 'name': 'Troy Cablevision, Inc.'
1139 'name': 'Tullahoma Utilities Board'
1142 'name': 'TV Cable of Rensselaer'
1151 'name': 'Twin Lakes'
1154 'name': 'Twin Valley'
1157 'name': 'Union Telephone Company'
1160 'name': 'United Communications - TN'
1163 'name': 'United Services'
1169 'name': 'USA Communications'
1172 'name': 'USA Communications/Shellsburg, IA'
1175 'name': 'Valley TeleCom Group'
1178 'name': 'Valley Telecommunications'
1181 'name': 'Valparaiso Broadband'
1184 'name': 'Vast Broadband'
1187 'name': 'Venture Communications Cooperative, Inc.'
1190 'name': 'Vernon Communications Co-op'
1192 'weh010-vicksburg': {
1193 'name': 'Vicksburg Video'
1196 'name': 'Vision Communications'
1199 'name': 'Volcano Vision, Inc.'
1202 'name': 'VolFirst / BLTV'
1211 'name': 'Vyve Broadband'
1214 'name': 'Wabash Mutual Telephone'
1217 'name': 'Waitsfield Cable'
1220 'name': 'Walnut Communications'
1226 'name': 'Waverly Communications Utility'
1232 'name': 'Webster-Calhoun Cooperative Telephone Association'
1235 'name': 'West Alabama TV Cable'
1238 'name': 'West Carolina Communications'
1241 'name': 'West Central Telephone Association'
1244 'name': 'West River Cooperative Telephone Company'
1247 'name': 'WesTel Systems'
1250 'name': 'Western Iowa Networks'
1253 'name': 'Whidbey Telecom'
1256 'name': 'White County Cable TV'
1265 'name': 'Wilkes Communications, Inc./RiverStreet Networks'
1268 'name': 'Wilson Communications'
1271 'name': 'Windomnet/SMBS'
1274 'name': 'Windstream Cable TV'
1277 'name': 'Winnebago Cooperative Telecom Association'
1283 'name': 'WTC Communications, Inc.'
1286 'name': 'Wyandotte Cable'
1289 'name': 'X-Stream Services'
1292 'name': 'XIT Communications'
1295 'name': 'Yelcot Communications'
1301 'name': 'Zito Media'
1306 class AdobePassIE(InfoExtractor
):
1307 _SERVICE_PROVIDER_TEMPLATE
= 'https://sp.auth.adobe.com/adobe-services/%s'
1308 _USER_AGENT
= 'Mozilla/5.0 (X11; Linux i686; rv:47.0) Gecko/20100101 Firefox/47.0'
1309 _MVPD_CACHE
= 'ap-mvpd'
1311 def _download_webpage_handle(self
, *args
, **kwargs
):
1312 headers
= kwargs
.get('headers', {})
1313 headers
.update(self
.geo_verification_headers())
1314 kwargs
['headers'] = headers
1315 return super(AdobePassIE
, self
)._download
_webpage
_handle
(*args
, **kwargs
)
1318 def _get_mvpd_resource(provider_id
, title
, guid
, rating
):
1319 channel
= etree
.Element('channel')
1320 channel_title
= etree
.SubElement(channel
, 'title')
1321 channel_title
.text
= provider_id
1322 item
= etree
.SubElement(channel
, 'item')
1323 resource_title
= etree
.SubElement(item
, 'title')
1324 resource_title
.text
= title
1325 resource_guid
= etree
.SubElement(item
, 'guid')
1326 resource_guid
.text
= guid
1327 resource_rating
= etree
.SubElement(item
, 'media:rating')
1328 resource_rating
.attrib
= {'scheme': 'urn:v-chip'}
1329 resource_rating
.text
= rating
1330 return '<rss version="2.0" xmlns:media="http://search.yahoo.com/mrss/">' + etree
.tostring(channel
).decode() + '</rss>'
1332 def _extract_mvpd_auth(self
, url
, video_id
, requestor_id
, resource
):
1333 def xml_text(xml_str
, tag
):
1334 return self
._search
_regex
(
1335 '<%s>(.+?)</%s>' % (tag
, tag
), xml_str
, tag
)
1337 def is_expired(token
, date_ele
):
1338 token_expires
= unified_timestamp(re
.sub(r
'[_ ]GMT', '', xml_text(token
, date_ele
)))
1339 return token_expires
and token_expires
<= int(time
.time())
1341 def post_form(form_page_res
, note
, data
={}):
1342 form_page
, urlh
= form_page_res
1343 post_url
= self
._html
_search
_regex
(r
'<form[^>]+action=(["\'])(?P
<url
>.+?
)\
1', form_page, 'post url
', group='url
')
1344 if not re.match(r'https?
://', post_url):
1345 post_url = compat_urlparse.urljoin(urlh.geturl(), post_url)
1346 form_data = self._hidden_inputs(form_page)
1347 form_data.update(data)
1348 return self._download_webpage_handle(
1349 post_url, video_id, note, data=urlencode_postdata(form_data), headers={
1350 'Content
-Type
': 'application
/x
-www
-form
-urlencoded
',
1353 def raise_mvpd_required():
1354 raise ExtractorError(
1355 'This video
is only available
for users of participating TV providers
. '
1356 'Use
--ap
-mso to specify Adobe Pass Multiple
-system operator Identifier
'
1357 'and --ap
-username
and --ap
-password
or --netrc to provide account credentials
.', expected=True)
1360 'ap_42
': 'anonymous
',
1361 'ap_11
': 'Linux i686
',
1362 'ap_z
': self._USER_AGENT,
1363 'User
-Agent
': self._USER_AGENT,
1366 guid = xml_text(resource, 'guid
') if '<' in resource else resource
1369 requestor_info = self._downloader.cache.load(self._MVPD_CACHE, requestor_id) or {}
1370 authn_token = requestor_info.get('authn_token
')
1371 if authn_token and is_expired(authn_token, 'simpleTokenExpires
'):
1374 # TODO add support for other TV Providers
1375 mso_id = self._downloader.params.get('ap_mso
')
1377 raise_mvpd_required()
1378 username, password = self._get_login_info('ap_username
', 'ap_password
', mso_id)
1379 if not username or not password:
1380 raise_mvpd_required()
1381 mso_info = MSO_INFO[mso_id]
1383 provider_redirect_page_res = self._download_webpage_handle(
1384 self._SERVICE_PROVIDER_TEMPLATE % 'authenticate
/saml
', video_id,
1385 'Downloading Provider Redirect Page
', query={
1388 'requestor_id
': requestor_id,
1389 'no_iframe
': 'false
',
1390 'domain_name
': 'adobe
.com
',
1391 'redirect_url
': url,
1394 if mso_id == 'Comcast_SSO
':
1395 # Comcast page flow varies by video site and whether you
1396 # are on Comcast's network
.
1397 provider_redirect_page
, urlh
= provider_redirect_page_res
1398 if 'automatically signing you in' in provider_redirect_page
:
1399 oauth_redirect_url
= self
._html
_search
_regex
(
1400 r
'window\.location\s*=\s*[\'"]([^\'"]+)',
1401 provider_redirect_page, 'oauth redirect
')
1402 self._download_webpage(
1403 oauth_redirect_url, video_id, 'Confirming auto login
')
1405 if '<form name
="signin"' in provider_redirect_page:
1406 provider_login_page_res = provider_redirect_page_res
1407 elif 'http
-equiv
="refresh"' in provider_redirect_page:
1408 oauth_redirect_url = self._html_search_regex(
1409 r'content
="0;\s*url=([^\'"]+)',
1410 provider_redirect_page, 'meta refresh redirect
')
1411 provider_login_page_res = self._download_webpage_handle(
1412 oauth_redirect_url, video_id,
1413 'Downloading Provider Login Page
')
1415 provider_login_page_res = post_form(
1416 provider_redirect_page_res,
1417 'Downloading Provider Login Page
')
1419 mvpd_confirm_page_res = post_form(
1420 provider_login_page_res, 'Logging
in', {
1421 mso_info['username_field
']: username,
1422 mso_info['password_field
']: password,
1424 mvpd_confirm_page, urlh = mvpd_confirm_page_res
1425 if '<button
class="submit" value
="Resume">Resume
</button
>' in mvpd_confirm_page:
1426 post_form(mvpd_confirm_page_res, 'Confirming Login
')
1427 elif mso_id == 'Verizon
':
1428 # In general, if you're connecting
from a Verizon
-assigned IP
,
1429 # you will not actually pass your credentials.
1430 provider_redirect_page
, urlh
= provider_redirect_page_res
1431 if 'Please wait ...' in provider_redirect_page
:
1432 saml_redirect_url
= self
._html
_search
_regex
(
1433 r
'self\.parent\.location=(["\'])(?P
<url
>.+?
)\
1',
1434 provider_redirect_page,
1435 'SAML Redirect URL
', group='url
')
1436 saml_login_page = self._download_webpage(
1437 saml_redirect_url, video_id,
1438 'Downloading SAML Login Page
')
1440 saml_login_page_res = post_form(
1441 provider_redirect_page_res, 'Logging
in', {
1442 mso_info['username_field
']: username,
1443 mso_info['password_field
']: password,
1445 saml_login_page, urlh = saml_login_page_res
1446 if 'Please
try again
.' in saml_login_page:
1447 raise ExtractorError(
1448 'We
\'re sorry
, but either the User ID
or Password entered
is not correct
.')
1449 saml_login_url = self._search_regex(
1450 r'xmlHttp\
.open\
("POST"\s
*,\s
*(["\'])(?P<url>.+?)\1',
1451 saml_login_page, 'SAML Login URL', group='url')
1452 saml_response_json = self._download_json(
1453 saml_login_url, video_id, 'Downloading SAML Response',
1454 headers={'Content-Type': 'text/xml'})
1455 self._download_webpage(
1456 saml_response_json['targetValue'], video_id,
1457 'Confirming Login', data=urlencode_postdata({
1458 'SAMLResponse': saml_response_json['SAMLResponse'],
1459 'RelayState': saml_response_json['RelayState']
1461 'Content-Type': 'application/x-www-form-urlencoded'
1464 provider_login_page_res = post_form(
1465 provider_redirect_page_res, 'Downloading Provider Login Page')
1466 mvpd_confirm_page_res = post_form(provider_login_page_res, 'Logging in', {
1467 mso_info.get('username_field', 'username'): username,
1468 mso_info.get('password_field', 'password'): password,
1470 if mso_id != 'Rogers':
1471 post_form(mvpd_confirm_page_res, 'Confirming Login')
1473 session = self._download_webpage(
1474 self._SERVICE_PROVIDER_TEMPLATE % 'session', video_id,
1475 'Retrieving Session', data=urlencode_postdata({
1477 'requestor_id': requestor_id,
1478 }), headers=mvpd_headers)
1479 if '<pendingLogout' in session:
1480 self._downloader.cache.store(self._MVPD_CACHE, requestor_id, {})
1483 authn_token = unescapeHTML(xml_text(session, 'authnToken'))
1484 requestor_info['authn_token'] = authn_token
1485 self._downloader.cache.store(self._MVPD_CACHE, requestor_id, requestor_info)
1487 authz_token = requestor_info.get(guid)
1488 if authz_token and is_expired(authz_token, 'simpleTokenTTL'):
1491 authorize = self._download_webpage(
1492 self._SERVICE_PROVIDER_TEMPLATE % 'authorize', video_id,
1493 'Retrieving Authorization Token', data=urlencode_postdata({
1494 'resource_id': resource,
1495 'requestor_id': requestor_id,
1496 'authentication_token': authn_token,
1497 'mso_id': xml_text(authn_token, 'simpleTokenMsoID'),
1499 }), headers=mvpd_headers)
1500 if '<pendingLogout' in authorize:
1501 self._downloader.cache.store(self._MVPD_CACHE, requestor_id, {})
1504 if '<error' in authorize:
1505 raise ExtractorError(xml_text(authorize, 'details'), expected=True)
1506 authz_token = unescapeHTML(xml_text(authorize, 'authzToken'))
1507 requestor_info[guid] = authz_token
1508 self._downloader.cache.store(self._MVPD_CACHE, requestor_id, requestor_info)
1510 mvpd_headers.update({
1511 'ap_19': xml_text(authn_token, 'simpleSamlNameID'),
1512 'ap_23': xml_text(authn_token, 'simpleSamlSessionIndex'),
1515 short_authorize = self._download_webpage(
1516 self._SERVICE_PROVIDER_TEMPLATE % 'shortAuthorize',
1517 video_id, 'Retrieving Media Token', data=urlencode_postdata({
1518 'authz_token': authz_token,
1519 'requestor_id': requestor_id,
1520 'session_guid': xml_text(authn_token, 'simpleTokenAuthenticationGuid'),
1521 'hashed_guid': 'false',
1522 }), headers=mvpd_headers)
1523 if '<pendingLogout' in short_authorize:
1524 self._downloader.cache.store(self._MVPD_CACHE, requestor_id, {})
1527 return short_authorize