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