1 # -*- coding: utf-8 -*-
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': '3 Rivers Communications'
33 'name': 'Access Montana'
35 'acecommunications': {
39 'name': 'Acme Communications'
42 'name': 'Adams Cable Service'
45 'name': 'Albany Mutual Telephone'
48 'name': 'Algona Municipal Utilities'
51 'name': 'All West Communications'
54 'name': 'Allen\'s Communications'
57 'name': 'Alliance Communications'
60 'name': 'ALLO Communications'
63 'name': 'Alpine Communications'
66 'name': 'American Broadband'
69 'name': 'American Broadband Missouri'
72 'name': 'American Community Networks'
75 'name': 'American Warrior Networks'
78 'name': 'Amherst Telephone/Tomorrow Valley'
84 'name': 'Arkwest Communications'
87 'name': 'Arthur Mutual Telephone Company'
93 'name': 'Ashland Home Net'
96 'name': 'Astound (now Wave)'
99 'name': 'ATC Broadband'
102 'name': 'ATC Communications'
105 'name': 'Ayersville Communications'
108 'name': 'Baldwin Lightstream'
114 'name': 'Bardstown Cable TV'
117 'name': 'Bay Country Communications'
120 'name': 'Beaver Creek Cooperative Telephone'
123 'name': 'Beaver Valley Cable'
126 'name': 'Bee Line Cable'
129 'name': 'Beehive Broadband'
135 'name': 'Bellevue Municipal Cable'
138 'name': 'Ben Lomand Connect / BLTV'
144 'name': 'Big Sandy Broadband'
147 'name': 'Bledsoe Telephone Cooperative'
150 'name': 'Blue Valley Tele-Communications'
153 'name': 'Brandenburg Telephone Co.'
156 'name': 'Bristol Tennessee Essential Services'
159 'name': 'Broadstripe'
162 'name': 'BTC Communications'
165 'name': 'BTC Vision - Nahunta'
168 'name': 'Bulloch Telephone Cooperative'
171 'name': 'Butler-Bremer Communications'
174 'name': 'C Spire SNAP'
177 'name': 'Cable Services Inc.'
180 'name': 'CableAmerica'
183 'name': 'CableSouth Media 3'
186 'name': 'Cam-Tel Company'
189 'name': 'Cameron Communications'
192 'name': 'Canby Telcom'
198 'name': 'Carnegie Cable'
207 'name': 'Catalina Broadband Solutions'
210 'name': 'CC Communications'
213 'name': 'CDE Lightband'
216 'name': 'Cedar Falls Utilities'
219 'name': 'Celect-Bloomer Telephone Area'
222 'name': 'Celect-Bruce Telephone Area'
225 'name': 'Celect-Citizens Connected Area'
228 'name': 'Celect-Elmwood/Spring Valley Area'
231 'name': 'Celect-Mosaic Telecom'
234 'name': 'Celect-West WI Telephone Area'
237 'name': 'Cellcom/Nsight Telservices'
243 'name': 'Central Scott / CSTV'
246 'name': 'Chaparral CableVision'
249 'name': 'Chariton Valley Communication Corporation, Inc.'
252 'name': 'Chatmoss Cablevision'
255 'name': 'Cherokee Communications'
258 'name': 'Chesapeake Bay Communications'
261 'name': 'Cim-Tel Cable, LLC.'
264 'name': 'Citizens Cablevision - Floyd, VA'
267 'name': 'Citizens Cablevision, Inc.'
270 'name': 'Citizens Fiber'
273 'name': 'Citizens Mutual'
276 'name': 'Citizens Telephone Corporation'
279 'name': 'City Of Monroe'
288 'name': 'Clarence Telephone and Cedar Communications'
291 'name': 'Clear Choice Communications'
294 'name': 'Click! Cable TV'
300 'name': 'CML Telephone Cooperative Association'
306 'name': 'Co-Mo Connect'
309 'name': 'Coast Communications'
312 'name': 'Coaxial Cable TV'
315 'name': 'Cobalt TV (Mid-State Community TV)'
318 'name': 'Columbia Power & Water Systems'
321 'name': 'Columbus Telephone'
324 'name': 'Communications 1 Cablevision, Inc.'
327 'name': 'Community Cable & Broadband'
330 'name': 'Community Communications Company'
336 'name': 'Complete Communication Services'
342 'name': 'ComSouth Telesys'
344 'consolidatedcable': {
345 'name': 'Consolidated'
348 'name': 'Conway Corporation'
351 'name': 'Coon Valley Telecommunications Inc'
354 'name': 'Cooperative Telephone Company'
360 'name': 'Craw-Kan Telephone'
363 'name': 'Crestview Cable Communications'
369 'name': 'Crosslake Communications'
372 'name': 'CTC - Brainerd MN'
375 'name': 'CTV-Beam - East Alabama'
378 'name': 'Cunningham Telephone & Cable'
381 'name': 'D & P Communications'
384 'name': 'Dakota Central Telecommunications'
387 'name': 'Delcambre Telephone LLC'
390 'name': 'Delta Telephone Company'
396 'name': 'Direct Communications'
399 'name': 'Doylestown Cable TV'
408 'name': 'DTC Cable (Delhi)'
411 'name': 'Dumont Telephone Company'
414 'name': 'Dunkerton Telephone Cooperative'
417 'name': 'Duo County Telecom'
420 'name': 'Eagle Communications'
423 'name': 'East Arkansas Cable TV'
426 'name': 'EATEL Video, LLC'
432 'name': 'Emery Telcom Video LLC'
435 'name': 'Empire Access'
438 'name': 'Endeavor Communications'
441 'name': 'Enhanced Telecommunications Corporation'
447 'name': 'EPB Smartnet'
450 'name': 'EPlus Broadband'
456 'name': 'Etex Communications'
459 'name': 'F&B Communications'
462 'name': 'Falcon Broadband'
465 'name': 'FamilyView CableVision'
468 'name': 'Farmers Mutual Telephone Company'
471 'name': 'Fayetteville Public Utilities'
477 'name': 'Fidelity Communications'
480 'name': 'FJ Communications'
483 'name': 'Flint River Communications'
486 'name': 'FMT - Jesup'
489 'name': 'Foothills Communications'
492 'name': 'Forsyth CableNet'
495 'name': 'Frankfort Plant Board'
498 'name': 'Franklin Telephone Company'
504 'name': 'Full Channel, Inc.'
507 'name': 'Gardonville Cooperative Telephone Association'
510 'name': 'GBT Communications, Inc.'
513 'name': 'Genuine Telecom'
516 'name': 'Giant Communications'
519 'name': 'Glasgow EPB'
522 'name': 'Glenwood Telecommunications'
525 'name': 'GLW Broadband Inc.'
528 'name': 'Golden West Cablevision'
531 'name': 'Grantsburg Telcom'
534 'name': 'Great Plains Communications'
537 'name': 'Gridley Cable Inc'
540 'name': 'H&B Cable Services'
543 'name': 'Haefele TV Inc.'
546 'name': 'Halstad Telephone Company'
549 'name': 'Harlan Municipal Utilities'
552 'name': 'Hart Communications'
555 'name': 'Hartelco TV'
558 'name': 'Heart of Iowa Communications Cooperative'
561 'name': 'Hickory Telephone Company'
564 'name': 'Highland Communication Services'
567 'name': 'Highland Media'
570 'name': 'Hilliary Communications'
573 'name': 'Hinton CATV Co.'
576 'name': 'HomeTel Entertainment, Inc.'
579 'name': 'Hood Canal Communications'
582 'name': 'Hope - Prescott Cable TV'
585 'name': 'Horizon Cable TV, Inc.'
588 'name': 'Horizon Chillicothe Telephone'
591 'name': 'HTC Communications Co. - IL'
594 'name': 'HTC Communications, Inc. - IA'
597 'name': 'Huxley Communications'
600 'name': 'ImOn Communications'
603 'name': 'Independence Telecommunications'
606 'name': 'Inland Networks'
609 'name': 'Innovative Cable TV St Croix'
612 'name': 'Innovative Cable TV St Thomas-St John'
615 'name': 'Inside Connect Cable'
618 'name': 'Integra Telecom'
621 'name': 'Interstate Telecommunications Coop'
624 'name': 'Irvine Cable'
627 'name': 'K2 Communications'
630 'name': 'Kalida Telephone Company, Inc.'
633 'name': 'Kalona Cooperative Telephone Company'
639 'name': 'KPU Telecommunications'
642 'name': 'Kuhn Communications, Inc.'
645 'name': 'Lakeland Communications'
651 'name': 'Laurel Highland Total Communications, Inc.'
654 'name': 'Lehigh Valley Cooperative Telephone'
657 'name': 'Limestone Cable/Bracken Cable'
669 'name': 'LocalTel Communications'
672 'name': 'Longview - Kilgore Cable TV'
675 'name': 'Lonsdale Video Ventures, LLC'
678 'name': 'Lost Nation-Elwood Telephone Co.'
681 'name': 'LPC Connect'
684 'name': 'Lumos Networks'
687 'name': 'Madison Communications'
690 'name': 'Madison County Cable Inc.'
693 'name': 'Mahaska Communication Group'
696 'name': 'Marne & Elk Horn Telephone Company'
699 'name': 'McClure Telephone Co.'
705 'name': 'Merrimac Communications Ltd.'
714 'name': 'Mid-Hudson Cable'
717 'name': 'Mid-Rivers Communications'
720 'name': 'Midstate Communications'
723 'name': 'Milford Communications'
732 'name': 'Mitchell Telecom'
738 'name': 'Mon-Cre TVE'
741 'name': 'Mountain Telephone'
744 'name': 'Mountain Village Cable'
747 'name': 'MTA Communications, LLC'
753 'name': 'MTC Technologies'
759 'name': 'MTCO Communications'
762 'name': 'Mulberry Telecommunications'
765 'name': 'Murray Electric System'
768 'name': 'MUS FiberNET'
771 'name': 'Muscatine Power & Water'
783 'name': 'Nebraska Central Telecom, Inc.'
786 'name': 'Nelsonville TV Cable'
792 'name': 'New Hope Telephone Cooperative'
798 'name': 'NineStar Connect'
804 'name': 'Nortex Communications'
807 'name': 'North Central Telephone Cooperative'
810 'name': 'Northland Communications'
813 'name': 'Northwest Communications'
816 'name': 'Norwood Light Broadband'
819 'name': 'Nsight Telservices'
825 'name': 'NTS Communications'
837 'name': 'OmniTel Communications'
840 'name': 'OneSource Communications'
843 'name': 'Opelika Power Services'
852 'name': 'OTEC Communication Company'
855 'name': 'Packerland Broadband'
858 'name': 'Panora Telco/Guthrie Center Communications'
861 'name': 'Park Region Telephone & Otter Tail Telcom'
864 'name': 'Partner Communications Cooperative'
870 'name': 'Paul Bunyan Communications'
873 'name': 'Pembroke Telephone Company'
876 'name': 'Peoples Rural Telephone Cooperative'
879 'name': 'PES Energize'
882 'name': 'Philippi Communications System'
885 'name': 'Phonoscope Cable'
888 'name': 'Pine Belt Communications, Inc.'
891 'name': 'Pine Bluff Cable TV'
894 'name': 'Pineland Telephone Cooperative'
897 'name': 'Pinpoint Communications'
900 'name': 'Pioneer Broadband'
903 'name': 'Pioneer Communications'
906 'name': 'Pioneer DTV'
909 'name': 'Plant TiftNet, Inc.'
918 'name': 'Polar Cablevision'
921 'name': 'Pottawatomie Telephone Co.'
924 'name': 'Premier Communications'
936 'name': 'Quality Cablevision'
939 'name': 'Radcliffe Telephone Company'
942 'name': 'Rainbow Communications'
945 'name': 'Rainier Connect'
948 'name': 'Ralls Technologies'
951 'name': 'RC Technologies'
954 'name': 'Red River Communications'
957 'name': 'Reedsburg Utility Commission'
960 'name': 'Reliance Connects- Oregon'
963 'name': 'Reserve Telecommunications'
966 'name': 'Resort TV Cable'
969 'name': 'Richland Grant Telephone Cooperative, Inc.'
972 'name': 'River Valley Telecommunications Coop'
975 'name': 'Rock Port Cablevision'
981 'name': 'RTC Communication Corp'
984 'name': 'RTC-Reservation Telephone Coop.'
987 'name': 'RTEC Communications'
993 'name': 'San Bruno Cable TV'
999 'name': 'SCI Broadband-Savage Communications Inc.'
1002 'name': 'Scottsboro Electric Power Board'
1005 'name': 'Scranton Telephone Company'
1014 'name': 'Sherwood Mutual Telephone Association, Inc.'
1017 'name': 'Silver Star Communications'
1020 'name': 'Sjoberg\'s Inc.'
1026 'name': 'SkyBest TV'
1029 'name': 'Smithville Communications'
1035 'name': 'South Central Rural Telephone Cooperative'
1038 'name': 'South Holt Cablevision, Inc.'
1041 'name': 'South Slope Cooperative Communications'
1044 'name': 'Spanish Fork Community Network'
1047 'name': 'Spencer Municipal Utilities'
1050 'name': 'Spillway Communications, Inc.'
1056 'name': 'St. Maarten Cable TV'
1059 'name': 'Star Communications'
1065 'name': 'STRATA Networks'
1068 'name': 'Sumner Cable TV'
1071 'name': 'Surry TV/PCSI TV'
1074 'name': 'Swayzee Communications'
1077 'name': 'Sweetwater Cable Television Co'
1079 'weh010-talequah': {
1080 'name': 'Tahlequah Cable TV'
1086 'name': 'Tele-Media Company'
1089 'name': 'The Community Agency'
1092 'name': 'Three River'
1095 'name': 'Town & Country Technologies'
1098 'name': 'Trans-Video'
1101 'name': 'Trenton TV Cable Company'
1104 'name': 'Tri County Communications Cooperative'
1107 'name': 'TriCounty Telecom'
1110 'name': 'TrioTel Communications, Inc.'
1113 'name': 'Troy Cablevision, Inc.'
1119 'name': 'Tullahoma Utilities Board'
1122 'name': 'TV Cable of Rensselaer'
1131 'name': 'Twin Lakes'
1134 'name': 'Twin Valley'
1137 'name': 'Union Telephone Company'
1140 'name': 'United Communications - TN'
1143 'name': 'United Services'
1149 'name': 'USA Communications'
1152 'name': 'USA Communications/Shellsburg, IA'
1155 'name': 'Valley TeleCom Group'
1158 'name': 'Valley Telecommunications'
1161 'name': 'Valparaiso Broadband'
1164 'name': 'Vast Broadband'
1167 'name': 'Venture Communications Cooperative, Inc.'
1170 'name': 'Vernon Communications Co-op'
1172 'weh010-vicksburg': {
1173 'name': 'Vicksburg Video'
1176 'name': 'Vision Communications'
1179 'name': 'Volcano Vision, Inc.'
1182 'name': 'VolFirst / BLTV'
1191 'name': 'Vyve Broadband'
1194 'name': 'Wabash Mutual Telephone'
1197 'name': 'Waitsfield Cable'
1200 'name': 'Walnut Communications'
1206 'name': 'Waverly Communications Utility'
1212 'name': 'Webster-Calhoun Cooperative Telephone Association'
1215 'name': 'West Alabama TV Cable'
1218 'name': 'West Carolina Communications'
1221 'name': 'West Central Telephone Association'
1224 'name': 'West River Cooperative Telephone Company'
1227 'name': 'WesTel Systems'
1230 'name': 'Western Iowa Networks'
1233 'name': 'Whidbey Telecom'
1236 'name': 'White County Cable TV'
1245 'name': 'Wilkes Communications, Inc./RiverStreet Networks'
1248 'name': 'Wilson Communications'
1251 'name': 'Windomnet/SMBS'
1254 'name': 'Windstream Cable TV'
1257 'name': 'Winnebago Cooperative Telecom Association'
1263 'name': 'WTC Communications, Inc.'
1266 'name': 'Wyandotte Cable'
1269 'name': 'X-Stream Services'
1272 'name': 'XIT Communications'
1275 'name': 'Yelcot Communications'
1281 'name': 'Zito Media'
1286 class AdobePassIE(InfoExtractor):
1287 _SERVICE_PROVIDER_TEMPLATE = 'https://sp.auth.adobe.com/adobe-services/%s'
1288 _USER_AGENT = 'Mozilla/5.0 (X11; Linux i686; rv:47.0) Gecko/20100101 Firefox/47.0'
1289 _MVPD_CACHE = 'ap-mvpd'
1292 def _get_mvpd_resource(provider_id, title, guid, rating):
1293 channel = etree.Element('channel')
1294 channel_title = etree.SubElement(channel, 'title')
1295 channel_title.text = provider_id
1296 item = etree.SubElement(channel, 'item')
1297 resource_title = etree.SubElement(item, 'title')
1298 resource_title.text = title
1299 resource_guid = etree.SubElement(item, 'guid')
1300 resource_guid.text = guid
1301 resource_rating = etree.SubElement(item, 'media:rating')
1302 resource_rating.attrib = {'scheme': 'urn:v-chip'}
1303 resource_rating.text = rating
1304 return '<rss version="2.0" xmlns:media="http://search.yahoo.com/mrss/">' + etree.tostring(channel).decode() + '</rss>'
1306 def _extract_mvpd_auth(self, url, video_id, requestor_id, resource):
1307 def xml_text(xml_str, tag):
1308 return self._search_regex(
1309 '<%s>(.+?)</%s>' % (tag, tag), xml_str, tag)
1311 def is_expired(token, date_ele):
1312 token_expires = unified_timestamp(re.sub(r'[_ ]GMT', '', xml_text(token, date_ele)))
1313 return token_expires and token_expires <= int(time.time())
1315 def post_form(form_page_res, note, data={}):
1316 form_page, urlh = form_page_res
1317 post_url = self._html_search_regex(r'<form[^>]+action=(["\'])(?P<url>.+?)\1', form_page, 'post url', group='url')
1318 if not re.match(r'https?://', post_url):
1319 post_url = compat_urlparse.urljoin(urlh.geturl(), post_url)
1320 form_data = self._hidden_inputs(form_page)
1321 form_data.update(data)
1322 return self._download_webpage_handle(
1323 post_url, video_id, note, data=urlencode_postdata(form_data), headers={
1324 'Content-Type': 'application/x-www-form-urlencoded',
1327 def raise_mvpd_required():
1328 raise ExtractorError(
1329 'This video is only available for users of participating TV providers. '
1330 'Use --ap-mso to specify Adobe Pass Multiple-system operator Identifier '
1331 'and --ap-username and --ap-password or --netrc to provide account credentials.', expected=True)
1334 'ap_42': 'anonymous',
1335 'ap_11': 'Linux i686',
1336 'ap_z': self._USER_AGENT,
1337 'User-Agent': self._USER_AGENT,
1340 guid = xml_text(resource, 'guid') if '<' in resource else resource
1343 requestor_info = self._downloader.cache.load(self._MVPD_CACHE, requestor_id) or {}
1344 authn_token = requestor_info.get('authn_token')
1345 if authn_token and is_expired(authn_token, 'simpleTokenExpires'):
1348 # TODO add support for other TV Providers
1349 mso_id = self._downloader.params.get('ap_mso')
1351 raise_mvpd_required()
1352 username, password = self._get_login_info('ap_username', 'ap_password', mso_id)
1353 if not username or not password:
1354 raise_mvpd_required()
1355 mso_info = MSO_INFO[mso_id]
1357 provider_redirect_page_res = self._download_webpage_handle(
1358 self._SERVICE_PROVIDER_TEMPLATE % 'authenticate/saml', video_id,
1359 'Downloading Provider Redirect Page', query={
1362 'requestor_id': requestor_id,
1363 'no_iframe': 'false',
1364 'domain_name': 'adobe.com',
1365 'redirect_url': url,
1367 provider_login_page_res = post_form(
1368 provider_redirect_page_res, 'Downloading Provider Login Page')
1369 mvpd_confirm_page_res = post_form(provider_login_page_res, 'Logging in', {
1370 mso_info.get('username_field', 'username'): username,
1371 mso_info.get('password_field', 'password'): password,
1373 if mso_id != 'Rogers':
1374 post_form(mvpd_confirm_page_res, 'Confirming Login')
1376 session = self._download_webpage(
1377 self._SERVICE_PROVIDER_TEMPLATE % 'session', video_id,
1378 'Retrieving Session', data=urlencode_postdata({
1380 'requestor_id': requestor_id,
1381 }), headers=mvpd_headers)
1382 if '<pendingLogout' in session:
1383 self._downloader.cache.store(self._MVPD_CACHE, requestor_id, {})
1386 authn_token = unescapeHTML(xml_text(session, 'authnToken'))
1387 requestor_info['authn_token'] = authn_token
1388 self._downloader.cache.store(self._MVPD_CACHE, requestor_id, requestor_info)
1390 authz_token = requestor_info.get(guid)
1391 if authz_token and is_expired(authz_token, 'simpleTokenTTL'):
1394 authorize = self._download_webpage(
1395 self._SERVICE_PROVIDER_TEMPLATE % 'authorize', video_id,
1396 'Retrieving Authorization Token', data=urlencode_postdata({
1397 'resource_id': resource,
1398 'requestor_id': requestor_id,
1399 'authentication_token': authn_token,
1400 'mso_id': xml_text(authn_token, 'simpleTokenMsoID'),
1402 }), headers=mvpd_headers)
1403 if '<pendingLogout' in authorize:
1404 self._downloader.cache.store(self._MVPD_CACHE, requestor_id, {})
1407 authz_token = unescapeHTML(xml_text(authorize, 'authzToken'))
1408 requestor_info[guid] = authz_token
1409 self._downloader.cache.store(self._MVPD_CACHE, requestor_id, requestor_info)
1411 mvpd_headers.update({
1412 'ap_19': xml_text(authn_token, 'simpleSamlNameID'),
1413 'ap_23': xml_text(authn_token, 'simpleSamlSessionIndex'),
1416 short_authorize = self._download_webpage(
1417 self._SERVICE_PROVIDER_TEMPLATE % 'shortAuthorize',
1418 video_id, 'Retrieving Media Token', data=urlencode_postdata({
1419 'authz_token': authz_token,
1420 'requestor_id': requestor_id,
1421 'session_guid': xml_text(authn_token, 'simpleTokenAuthenticationGuid'),
1422 'hashed_guid': 'false',
1423 }), headers=mvpd_headers)
1424 if '<pendingLogout' in short_authorize:
1425 self._downloader.cache.store(self._MVPD_CACHE, requestor_id, {})
1428 return short_authorize