2 from __future__ import unicode_literals
6 import xml.etree.ElementTree as etree
8 from .common import InfoExtractor
24 'username_field': 'username',
25 'password_field': 'password',
29 'username_field': 'UserName',
30 'password_field': 'UserPassword',
33 'name': 'Comcast XFINITY',
34 'username_field': 'user',
35 'password_field': 'passwd',
38 'name': 'Time Warner Cable | Spectrum',
39 'username_field': 'Ecom_User_ID',
40 'password_field': 'Ecom_Password',
43 'name': 'Bright House Networks | Spectrum',
44 'username_field': 'j_username',
45 'password_field': 'j_password',
48 'name': 'Charter Spectrum',
49 'username_field': 'IDToken1',
50 'password_field': 'IDToken2',
53 'name': 'Verizon FiOS',
54 'username_field': 'IDToken1',
55 'password_field': 'IDToken2',
58 'name': '3 Rivers Communications'
61 'name': 'Access Montana'
63 'acecommunications': {
67 'name': 'Acme Communications'
70 'name': 'Adams Cable Service'
73 'name': 'Albany Mutual Telephone'
76 'name': 'Algona Municipal Utilities'
79 'name': 'All West Communications'
82 'name': 'Allen\'s Communications'
85 'name': 'Alliance Communications'
88 'name': 'ALLO Communications'
91 'name': 'Alpine Communications'
94 'name': 'American Broadband'
97 'name': 'American Broadband Missouri'
100 'name': 'American Community Networks'
103 'name': 'American Warrior Networks'
106 'name': 'Amherst Telephone/Tomorrow Valley'
112 'name': 'Arkwest Communications'
115 'name': 'Arthur Mutual Telephone Company'
121 'name': 'Ashland Home Net'
124 'name': 'Astound (now Wave)'
127 'name': 'ATC Broadband'
130 'name': 'ATC Communications'
133 'name': 'Ayersville Communications'
136 'name': 'Baldwin Lightstream'
142 'name': 'Bardstown Cable TV'
145 'name': 'Bay Country Communications'
148 'name': 'Beaver Creek Cooperative Telephone'
151 'name': 'Beaver Valley Cable'
154 'name': 'Bee Line Cable'
157 'name': 'Beehive Broadband'
163 'name': 'Bellevue Municipal Cable'
166 'name': 'Ben Lomand Connect / BLTV'
172 'name': 'Big Sandy Broadband'
175 'name': 'Bledsoe Telephone Cooperative'
178 'name': 'Blue Valley Tele-Communications'
181 'name': 'Brandenburg Telephone Co.'
184 'name': 'Bristol Tennessee Essential Services'
187 'name': 'Broadstripe'
190 'name': 'BTC Communications'
193 'name': 'BTC Vision - Nahunta'
196 'name': 'Bulloch Telephone Cooperative'
199 'name': 'Butler-Bremer Communications'
202 'name': 'C Spire SNAP'
205 'name': 'Cable Services Inc.'
208 'name': 'CableAmerica'
211 'name': 'CableSouth Media 3'
214 'name': 'Cam-Tel Company'
217 'name': 'Cameron Communications'
220 'name': 'Canby Telcom'
226 'name': 'Carnegie Cable'
235 'name': 'Catalina Broadband Solutions'
238 'name': 'CC Communications'
241 'name': 'CDE Lightband'
244 'name': 'Cedar Falls Utilities'
247 'name': 'Celect-Bloomer Telephone Area'
250 'name': 'Celect-Bruce Telephone Area'
253 'name': 'Celect-Citizens Connected Area'
256 'name': 'Celect-Elmwood/Spring Valley Area'
259 'name': 'Celect-Mosaic Telecom'
262 'name': 'Celect-West WI Telephone Area'
265 'name': 'Cellcom/Nsight Telservices'
271 'name': 'Central Scott / CSTV'
274 'name': 'Chaparral CableVision'
277 'name': 'Chariton Valley Communication Corporation, Inc.'
280 'name': 'Chatmoss Cablevision'
283 'name': 'Cherokee Communications'
286 'name': 'Chesapeake Bay Communications'
289 'name': 'Cim-Tel Cable, LLC.'
292 'name': 'Citizens Cablevision - Floyd, VA'
295 'name': 'Citizens Cablevision, Inc.'
298 'name': 'Citizens Fiber'
301 'name': 'Citizens Mutual'
304 'name': 'Citizens Telephone Corporation'
307 'name': 'City Of Monroe'
316 'name': 'Clarence Telephone and Cedar Communications'
319 'name': 'Clear Choice Communications'
322 'name': 'Click! Cable TV'
328 'name': 'CML Telephone Cooperative Association'
334 'name': 'Co-Mo Connect'
337 'name': 'Coast Communications'
340 'name': 'Coaxial Cable TV'
343 'name': 'Cobalt TV (Mid-State Community TV)'
346 'name': 'Columbia Power & Water Systems'
349 'name': 'Columbus Telephone'
352 'name': 'Communications 1 Cablevision, Inc.'
355 'name': 'Community Cable & Broadband'
358 'name': 'Community Communications Company'
364 'name': 'Complete Communication Services'
370 'name': 'ComSouth Telesys'
372 'consolidatedcable': {
373 'name': 'Consolidated'
376 'name': 'Conway Corporation'
379 'name': 'Coon Valley Telecommunications Inc'
382 'name': 'Cooperative Telephone Company'
388 'name': 'Craw-Kan Telephone'
391 'name': 'Crestview Cable Communications'
397 'name': 'Crosslake Communications'
400 'name': 'CTC - Brainerd MN'
403 'name': 'CTV-Beam - East Alabama'
406 'name': 'Cunningham Telephone & Cable'
409 'name': 'D & P Communications'
412 'name': 'Dakota Central Telecommunications'
415 'name': 'Delcambre Telephone LLC'
418 'name': 'Delta Telephone Company'
424 'name': 'Direct Communications'
427 'name': 'Doylestown Cable TV'
436 'name': 'DTC Cable (Delhi)'
439 'name': 'Dumont Telephone Company'
442 'name': 'Dunkerton Telephone Cooperative'
445 'name': 'Duo County Telecom'
448 'name': 'Eagle Communications'
451 'name': 'East Arkansas Cable TV'
454 'name': 'EATEL Video, LLC'
460 'name': 'Emery Telcom Video LLC'
463 'name': 'Empire Access'
466 'name': 'Endeavor Communications'
469 'name': 'Enhanced Telecommunications Corporation'
475 'name': 'EPB Smartnet'
478 'name': 'EPlus Broadband'
484 'name': 'Etex Communications'
487 'name': 'F&B Communications'
490 'name': 'Falcon Broadband'
493 'name': 'FamilyView CableVision'
496 'name': 'Farmers Mutual Telephone Company'
499 'name': 'Fayetteville Public Utilities'
505 'name': 'Fidelity Communications'
508 'name': 'FJ Communications'
511 'name': 'Flint River Communications'
514 'name': 'FMT - Jesup'
517 'name': 'Foothills Communications'
520 'name': 'Forsyth CableNet'
523 'name': 'Frankfort Plant Board'
526 'name': 'Franklin Telephone Company'
532 'name': 'Full Channel, Inc.'
535 'name': 'Gardonville Cooperative Telephone Association'
538 'name': 'GBT Communications, Inc.'
541 'name': 'Genuine Telecom'
544 'name': 'Giant Communications'
547 'name': 'Glasgow EPB'
550 'name': 'Glenwood Telecommunications'
553 'name': 'GLW Broadband Inc.'
556 'name': 'Golden West Cablevision'
559 'name': 'Grantsburg Telcom'
562 'name': 'Great Plains Communications'
565 'name': 'Gridley Cable Inc'
568 'name': 'H&B Cable Services'
571 'name': 'Haefele TV Inc.'
574 'name': 'Halstad Telephone Company'
577 'name': 'Harlan Municipal Utilities'
580 'name': 'Hart Communications'
583 'name': 'Hartelco TV'
586 'name': 'Heart of Iowa Communications Cooperative'
589 'name': 'Hickory Telephone Company'
592 'name': 'Highland Communication Services'
595 'name': 'Highland Media'
598 'name': 'Hilliary Communications'
601 'name': 'Hinton CATV Co.'
604 'name': 'HomeTel Entertainment, Inc.'
607 'name': 'Hood Canal Communications'
610 'name': 'Hope - Prescott Cable TV'
613 'name': 'Horizon Cable TV, Inc.'
616 'name': 'Horizon Chillicothe Telephone'
619 'name': 'HTC Communications Co. - IL'
622 'name': 'HTC Communications, Inc. - IA'
625 'name': 'Huxley Communications'
628 'name': 'ImOn Communications'
631 'name': 'Independence Telecommunications'
634 'name': 'Inland Networks'
637 'name': 'Innovative Cable TV St Croix'
640 'name': 'Innovative Cable TV St Thomas-St John'
643 'name': 'Inside Connect Cable'
646 'name': 'Integra Telecom'
649 'name': 'Interstate Telecommunications Coop'
652 'name': 'Irvine Cable'
655 'name': 'K2 Communications'
658 'name': 'Kalida Telephone Company, Inc.'
661 'name': 'Kalona Cooperative Telephone Company'
667 'name': 'KPU Telecommunications'
670 'name': 'Kuhn Communications, Inc.'
673 'name': 'Lakeland Communications'
679 'name': 'Laurel Highland Total Communications, Inc.'
682 'name': 'Lehigh Valley Cooperative Telephone'
685 'name': 'Limestone Cable/Bracken Cable'
697 'name': 'LocalTel Communications'
700 'name': 'Longview - Kilgore Cable TV'
703 'name': 'Lonsdale Video Ventures, LLC'
706 'name': 'Lost Nation-Elwood Telephone Co.'
709 'name': 'LPC Connect'
712 'name': 'Lumos Networks'
715 'name': 'Madison Communications'
718 'name': 'Madison County Cable Inc.'
721 'name': 'Mahaska Communication Group'
724 'name': 'Marne & Elk Horn Telephone Company'
727 'name': 'McClure Telephone Co.'
733 'name': 'Merrimac Communications Ltd.'
742 'name': 'Mid-Hudson Cable'
745 'name': 'Mid-Rivers Communications'
748 'name': 'Midstate Communications'
751 'name': 'Milford Communications'
760 'name': 'Mitchell Telecom'
766 'name': 'Mon-Cre TVE'
769 'name': 'Mountain Telephone'
772 'name': 'Mountain Village Cable'
775 'name': 'MTA Communications, LLC'
781 'name': 'MTC Technologies'
787 'name': 'MTCO Communications'
790 'name': 'Mulberry Telecommunications'
793 'name': 'Murray Electric System'
796 'name': 'MUS FiberNET'
799 'name': 'Muscatine Power & Water'
811 'name': 'Nebraska Central Telecom, Inc.'
814 'name': 'Nelsonville TV Cable'
820 'name': 'New Hope Telephone Cooperative'
826 'name': 'NineStar Connect'
832 'name': 'Nortex Communications'
835 'name': 'North Central Telephone Cooperative'
838 'name': 'Northland Communications'
841 'name': 'Northwest Communications'
844 'name': 'Norwood Light Broadband'
847 'name': 'Nsight Telservices'
853 'name': 'NTS Communications'
865 'name': 'OmniTel Communications'
868 'name': 'OneSource Communications'
871 'name': 'Opelika Power Services'
880 'name': 'OTEC Communication Company'
883 'name': 'Packerland Broadband'
886 'name': 'Panora Telco/Guthrie Center Communications'
889 'name': 'Park Region Telephone & Otter Tail Telcom'
892 'name': 'Partner Communications Cooperative'
898 'name': 'Paul Bunyan Communications'
901 'name': 'Pembroke Telephone Company'
904 'name': 'Peoples Rural Telephone Cooperative'
907 'name': 'PES Energize'
910 'name': 'Philippi Communications System'
913 'name': 'Phonoscope Cable'
916 'name': 'Pine Belt Communications, Inc.'
919 'name': 'Pine Bluff Cable TV'
922 'name': 'Pineland Telephone Cooperative'
925 'name': 'Pinpoint Communications'
928 'name': 'Pioneer Broadband'
931 'name': 'Pioneer Communications'
934 'name': 'Pioneer DTV'
937 'name': 'Plant TiftNet, Inc.'
946 'name': 'Polar Cablevision'
949 'name': 'Pottawatomie Telephone Co.'
952 'name': 'Premier Communications'
964 'name': 'Quality Cablevision'
967 'name': 'Radcliffe Telephone Company'
970 'name': 'Rainbow Communications'
973 'name': 'Rainier Connect'
976 'name': 'Ralls Technologies'
979 'name': 'RC Technologies'
982 'name': 'Red River Communications'
985 'name': 'Reedsburg Utility Commission'
988 'name': 'Reliance Connects- Oregon'
991 'name': 'Reserve Telecommunications'
994 'name': 'Resort TV Cable'
997 'name': 'Richland Grant Telephone Cooperative, Inc.'
1000 'name': 'River Valley Telecommunications Coop'
1003 'name': 'Rock Port Cablevision'
1009 'name': 'RTC Communication Corp'
1012 'name': 'RTC-Reservation Telephone Coop.'
1015 'name': 'RTEC Communications'
1021 'name': 'San Bruno Cable TV'
1027 'name': 'SCI Broadband-Savage Communications Inc.'
1030 'name': 'Scottsboro Electric Power Board'
1033 'name': 'Scranton Telephone Company'
1042 'name': 'Sherwood Mutual Telephone Association, Inc.'
1045 'name': 'Silver Star Communications'
1048 'name': 'Sjoberg\'s Inc.'
1054 'name': 'SkyBest TV'
1057 'name': 'Smithville Communications'
1063 'name': 'South Central Rural Telephone Cooperative'
1066 'name': 'South Holt Cablevision, Inc.'
1069 'name': 'South Slope Cooperative Communications'
1072 'name': 'Spanish Fork Community Network'
1075 'name': 'Spencer Municipal Utilities'
1078 'name': 'Spillway Communications, Inc.'
1084 'name': 'St. Maarten Cable TV'
1087 'name': 'Star Communications'
1093 'name': 'STRATA Networks'
1096 'name': 'Sumner Cable TV'
1099 'name': 'Surry TV/PCSI TV'
1102 'name': 'Swayzee Communications'
1105 'name': 'Sweetwater Cable Television Co'
1107 'weh010-talequah': {
1108 'name': 'Tahlequah Cable TV'
1114 'name': 'Tele-Media Company'
1117 'name': 'The Community Agency'
1120 'name': 'Three River'
1123 'name': 'Town & Country Technologies'
1126 'name': 'Trans-Video'
1129 'name': 'Trenton TV Cable Company'
1132 'name': 'Tri County Communications Cooperative'
1135 'name': 'TriCounty Telecom'
1138 'name': 'TrioTel Communications, Inc.'
1141 'name': 'Troy Cablevision, Inc.'
1147 'name': 'Tullahoma Utilities Board'
1150 'name': 'TV Cable of Rensselaer'
1159 'name': 'Twin Lakes'
1162 'name': 'Twin Valley'
1165 'name': 'Union Telephone Company'
1168 'name': 'United Communications - TN'
1171 'name': 'United Services'
1177 'name': 'USA Communications'
1180 'name': 'USA Communications/Shellsburg, IA'
1183 'name': 'Valley TeleCom Group'
1186 'name': 'Valley Telecommunications'
1189 'name': 'Valparaiso Broadband'
1192 'name': 'Vast Broadband'
1195 'name': 'Venture Communications Cooperative, Inc.'
1198 'name': 'Vernon Communications Co-op'
1200 'weh010-vicksburg': {
1201 'name': 'Vicksburg Video'
1204 'name': 'Vision Communications'
1207 'name': 'Volcano Vision, Inc.'
1210 'name': 'VolFirst / BLTV'
1219 'name': 'Vyve Broadband'
1222 'name': 'Wabash Mutual Telephone'
1225 'name': 'Waitsfield Cable'
1228 'name': 'Walnut Communications'
1234 'name': 'Waverly Communications Utility'
1240 'name': 'Webster-Calhoun Cooperative Telephone Association'
1243 'name': 'West Alabama TV Cable'
1246 'name': 'West Carolina Communications'
1249 'name': 'West Central Telephone Association'
1252 'name': 'West River Cooperative Telephone Company'
1255 'name': 'WesTel Systems'
1258 'name': 'Western Iowa Networks'
1261 'name': 'Whidbey Telecom'
1264 'name': 'White County Cable TV'
1273 'name': 'Wilkes Communications, Inc./RiverStreet Networks'
1276 'name': 'Wilson Communications'
1279 'name': 'Windomnet/SMBS'
1282 'name': 'Windstream Cable TV'
1285 'name': 'Winnebago Cooperative Telecom Association'
1291 'name': 'WTC Communications, Inc.'
1294 'name': 'Wyandotte Cable'
1297 'name': 'X-Stream Services'
1300 'name': 'XIT Communications'
1303 'name': 'Yelcot Communications'
1309 'name': 'Zito Media'
1314 class AdobePassIE(InfoExtractor):
1315 _SERVICE_PROVIDER_TEMPLATE = 'https://sp.auth.adobe.com/adobe-services/%s'
1316 _USER_AGENT = 'Mozilla/5.0 (X11; Linux i686; rv:47.0) Gecko/20100101 Firefox/47.0'
1317 _MVPD_CACHE = 'ap-mvpd'
1319 def _download_webpage_handle(self, *args, **kwargs):
1320 headers = kwargs.get('headers', {})
1321 headers.update(self.geo_verification_headers())
1322 kwargs['headers'] = headers
1323 return super(AdobePassIE, self)._download_webpage_handle(
1324 *args, **compat_kwargs(kwargs))
1327 def _get_mvpd_resource(provider_id, title, guid, rating):
1328 channel = etree.Element('channel')
1329 channel_title = etree.SubElement(channel, 'title')
1330 channel_title.text = provider_id
1331 item = etree.SubElement(channel, 'item')
1332 resource_title = etree.SubElement(item, 'title')
1333 resource_title.text = title
1334 resource_guid = etree.SubElement(item, 'guid')
1335 resource_guid.text = guid
1336 resource_rating = etree.SubElement(item, 'media:rating')
1337 resource_rating.attrib = {'scheme': 'urn:v-chip'}
1338 resource_rating.text = rating
1339 return '<rss version="2.0" xmlns:media="http://search.yahoo.com/mrss/">' + etree.tostring(channel).decode() + '</rss>'
1341 def _extract_mvpd_auth(self, url, video_id, requestor_id, resource):
1342 def xml_text(xml_str, tag):
1343 return self._search_regex(
1344 '<%s>(.+?)</%s>' % (tag, tag), xml_str, tag)
1346 def is_expired(token, date_ele):
1347 token_expires = unified_timestamp(re.sub(r'[_ ]GMT', '', xml_text(token, date_ele)))
1348 return token_expires and token_expires <= int(time.time())
1350 def post_form(form_page_res, note, data={}):
1351 form_page, urlh = form_page_res
1352 post_url = self._html_search_regex(r'<form[^>]+action=(["\'])(?P<url>.+?)\1', form_page, 'post url', group='url')
1353 if not re.match(r'https?://', post_url):
1354 post_url = compat_urlparse.urljoin(urlh.geturl(), post_url)
1355 form_data = self._hidden_inputs(form_page)
1356 form_data.update(data)
1357 return self._download_webpage_handle(
1358 post_url, video_id, note, data=urlencode_postdata(form_data), headers={
1359 'Content-Type': 'application/x-www-form-urlencoded',
1362 def raise_mvpd_required():
1363 raise ExtractorError(
1364 'This video is only available for users of participating TV providers. '
1365 'Use --ap-mso to specify Adobe Pass Multiple-system operator Identifier '
1366 'and --ap-username and --ap-password or --netrc to provide account credentials.', expected=True)
1369 'ap_42': 'anonymous',
1370 'ap_11': 'Linux i686',
1371 'ap_z': self._USER_AGENT,
1372 'User-Agent': self._USER_AGENT,
1375 guid = xml_text(resource, 'guid') if '<' in resource else resource
1378 requestor_info = self._downloader.cache.load(self._MVPD_CACHE, requestor_id) or {}
1379 authn_token = requestor_info.get('authn_token')
1380 if authn_token and is_expired(authn_token, 'simpleTokenExpires'):
1383 # TODO add support for other TV Providers
1384 mso_id = self._downloader.params.get('ap_mso')
1386 raise_mvpd_required()
1387 username, password = self._get_login_info('ap_username', 'ap_password', mso_id)
1388 if not username or not password:
1389 raise_mvpd_required()
1390 mso_info = MSO_INFO[mso_id]
1392 provider_redirect_page_res = self._download_webpage_handle(
1393 self._SERVICE_PROVIDER_TEMPLATE % 'authenticate/saml', video_id,
1394 'Downloading Provider Redirect Page', query={
1397 'requestor_id': requestor_id,
1398 'no_iframe': 'false',
1399 'domain_name': 'adobe.com',
1400 'redirect_url': url,
1403 if mso_id == 'Comcast_SSO':
1404 # Comcast page flow varies by video site and whether you
1405 # are on Comcast's network.
1406 provider_redirect_page, urlh = provider_redirect_page_res
1407 if 'automatically signing you in' in provider_redirect_page:
1408 oauth_redirect_url = self._html_search_regex(
1409 r'window\.location\s*=\s*[\'"]([^\'"]+)',
1410 provider_redirect_page, 'oauth redirect')
1411 self._download_webpage(
1412 oauth_redirect_url, video_id, 'Confirming auto login')
1414 if '<form name="signin"' in provider_redirect_page:
1415 provider_login_page_res = provider_redirect_page_res
1416 elif 'http-equiv="refresh"' in provider_redirect_page:
1417 oauth_redirect_url = self._html_search_regex(
1418 r'content="0;\s*url=([^\'"]+)',
1419 provider_redirect_page, 'meta refresh redirect')
1420 provider_login_page_res = self._download_webpage_handle(
1421 oauth_redirect_url, video_id,
1422 'Downloading Provider Login Page')
1424 provider_login_page_res = post_form(
1425 provider_redirect_page_res,
1426 'Downloading Provider Login Page')
1428 mvpd_confirm_page_res = post_form(
1429 provider_login_page_res, 'Logging in', {
1430 mso_info['username_field']: username,
1431 mso_info['password_field']: password,
1433 mvpd_confirm_page, urlh = mvpd_confirm_page_res
1434 if '<button class="submit" value="Resume">Resume</button>' in mvpd_confirm_page:
1435 post_form(mvpd_confirm_page_res, 'Confirming Login')
1436 elif mso_id == 'Verizon':
1437 # In general, if you're connecting from a Verizon-assigned IP,
1438 # you will not actually pass your credentials.
1439 provider_redirect_page, urlh = provider_redirect_page_res
1440 if 'Please wait ...' in provider_redirect_page:
1441 saml_redirect_url = self._html_search_regex(
1442 r'self\.parent\.location=(["\'])(?P<url>.+?)\1',
1443 provider_redirect_page,
1444 'SAML Redirect URL', group='url')
1445 saml_login_page = self._download_webpage(
1446 saml_redirect_url, video_id,
1447 'Downloading SAML Login Page')
1449 saml_login_page_res = post_form(
1450 provider_redirect_page_res, 'Logging in', {
1451 mso_info['username_field']: username,
1452 mso_info['password_field']: password,
1454 saml_login_page, urlh = saml_login_page_res
1455 if 'Please try again.' in saml_login_page:
1456 raise ExtractorError(
1457 'We\'re sorry, but either the User ID or Password entered is not correct.')
1458 saml_login_url = self._search_regex(
1459 r'xmlHttp\.open\("POST"\s*,\s*(["\'])(?P<url>.+?)\1',
1460 saml_login_page, 'SAML Login URL', group='url')
1461 saml_response_json = self._download_json(
1462 saml_login_url, video_id, 'Downloading SAML Response',
1463 headers={'Content-Type': 'text/xml'})
1464 self._download_webpage(
1465 saml_response_json['targetValue'], video_id,
1466 'Confirming Login', data=urlencode_postdata({
1467 'SAMLResponse': saml_response_json['SAMLResponse'],
1468 'RelayState': saml_response_json['RelayState']
1470 'Content-Type': 'application/x-www-form-urlencoded'
1473 provider_login_page_res = post_form(
1474 provider_redirect_page_res, 'Downloading Provider Login Page')
1475 mvpd_confirm_page_res = post_form(provider_login_page_res, 'Logging in', {
1476 mso_info.get('username_field', 'username'): username,
1477 mso_info.get('password_field', 'password'): password,
1479 if mso_id != 'Rogers':
1480 post_form(mvpd_confirm_page_res, 'Confirming Login')
1482 session = self._download_webpage(
1483 self._SERVICE_PROVIDER_TEMPLATE % 'session', video_id,
1484 'Retrieving Session', data=urlencode_postdata({
1486 'requestor_id': requestor_id,
1487 }), headers=mvpd_headers)
1488 if '<pendingLogout' in session:
1489 self._downloader.cache.store(self._MVPD_CACHE, requestor_id, {})
1492 authn_token = unescapeHTML(xml_text(session, 'authnToken'))
1493 requestor_info['authn_token'] = authn_token
1494 self._downloader.cache.store(self._MVPD_CACHE, requestor_id, requestor_info)
1496 authz_token = requestor_info.get(guid)
1497 if authz_token and is_expired(authz_token, 'simpleTokenTTL'):
1500 authorize = self._download_webpage(
1501 self._SERVICE_PROVIDER_TEMPLATE % 'authorize', video_id,
1502 'Retrieving Authorization Token', data=urlencode_postdata({
1503 'resource_id': resource,
1504 'requestor_id': requestor_id,
1505 'authentication_token': authn_token,
1506 'mso_id': xml_text(authn_token, 'simpleTokenMsoID'),
1508 }), headers=mvpd_headers)
1509 if '<pendingLogout' in authorize:
1510 self._downloader.cache.store(self._MVPD_CACHE, requestor_id, {})
1513 if '<error' in authorize:
1514 raise ExtractorError(xml_text(authorize, 'details'), expected=True)
1515 authz_token = unescapeHTML(xml_text(authorize, 'authzToken'))
1516 requestor_info[guid] = authz_token
1517 self._downloader.cache.store(self._MVPD_CACHE, requestor_id, requestor_info)
1519 mvpd_headers.update({
1520 'ap_19': xml_text(authn_token, 'simpleSamlNameID'),
1521 'ap_23': xml_text(authn_token, 'simpleSamlSessionIndex'),
1524 short_authorize = self._download_webpage(
1525 self._SERVICE_PROVIDER_TEMPLATE % 'shortAuthorize',
1526 video_id, 'Retrieving Media Token', data=urlencode_postdata({
1527 'authz_token': authz_token,
1528 'requestor_id': requestor_id,
1529 'session_guid': xml_text(authn_token, 'simpleTokenAuthenticationGuid'),
1530 'hashed_guid': 'false',
1531 }), headers=mvpd_headers)
1532 if '<pendingLogout' in short_authorize:
1533 self._downloader.cache.store(self._MVPD_CACHE, requestor_id, {})
1536 return short_authorize