[adobepass] Add support for Brighthouse MSO
[youtube-dl] / youtube_dl / extractor / adobepass.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 import re
5 import time
6 import xml.etree.ElementTree as etree
7
8 from .common import InfoExtractor
9 from ..compat import compat_urlparse
10 from ..utils import (
11     unescapeHTML,
12     urlencode_postdata,
13     unified_timestamp,
14     ExtractorError,
15 )
16
17
18 MSO_INFO = {
19     'DTV': {
20         'name': 'DIRECTV',
21         'username_field': 'username',
22         'password_field': 'password',
23     },
24     'Rogers': {
25         'name': 'Rogers',
26         'username_field': 'UserName',
27         'password_field': 'UserPassword',
28     },
29     'Comcast_SSO': {
30         'name': 'Comcast XFINITY',
31         'username_field': 'user',
32         'password_field': 'passwd',
33     },
34     'TWC': {
35         'name': 'Time Warner Cable | Spectrum',
36         'username_field': 'Ecom_User_ID',
37         'password_field': 'Ecom_Password',
38     },
39     'Brighthouse': {
40         'name': 'Bright House Networks | Spectrum',
41         'username_field': 'j_username',
42         'password_field': 'j_password',
43     },
44     'Charter_Direct': {
45         'name': 'Charter Spectrum',
46         'username_field': 'IDToken1',
47         'password_field': 'IDToken2',
48     },
49     'Verizon': {
50         'name': 'Verizon FiOS',
51         'username_field': 'IDToken1',
52         'password_field': 'IDToken2',
53     },
54     'thr030': {
55         'name': '3 Rivers Communications'
56     },
57     'com140': {
58         'name': 'Access Montana'
59     },
60     'acecommunications': {
61         'name': 'AcenTek'
62     },
63     'acm010': {
64         'name': 'Acme Communications'
65     },
66     'ada020': {
67         'name': 'Adams Cable Service'
68     },
69     'alb020': {
70         'name': 'Albany Mutual Telephone'
71     },
72     'algona': {
73         'name': 'Algona Municipal Utilities'
74     },
75     'allwest': {
76         'name': 'All West Communications'
77     },
78     'all025': {
79         'name': 'Allen\'s Communications'
80     },
81     'spl010': {
82         'name': 'Alliance Communications'
83     },
84     'all070': {
85         'name': 'ALLO Communications'
86     },
87     'alpine': {
88         'name': 'Alpine Communications'
89     },
90     'hun015': {
91         'name': 'American Broadband'
92     },
93     'nwc010': {
94         'name': 'American Broadband Missouri'
95     },
96     'com130-02': {
97         'name': 'American Community Networks'
98     },
99     'com130-01': {
100         'name': 'American Warrior Networks'
101     },
102     'tom020': {
103         'name': 'Amherst Telephone/Tomorrow Valley'
104     },
105     'tvc020': {
106         'name': 'Andycable'
107     },
108     'arkwest': {
109         'name': 'Arkwest Communications'
110     },
111     'art030': {
112         'name': 'Arthur Mutual Telephone Company'
113     },
114     'arvig': {
115         'name': 'Arvig'
116     },
117     'nttcash010': {
118         'name': 'Ashland Home Net'
119     },
120     'astound': {
121         'name': 'Astound (now Wave)'
122     },
123     'dix030': {
124         'name': 'ATC Broadband'
125     },
126     'ara010': {
127         'name': 'ATC Communications'
128     },
129     'she030-02': {
130         'name': 'Ayersville Communications'
131     },
132     'baldwin': {
133         'name': 'Baldwin Lightstream'
134     },
135     'bal040': {
136         'name': 'Ballard TV'
137     },
138     'cit025': {
139         'name': 'Bardstown Cable TV'
140     },
141     'bay030': {
142         'name': 'Bay Country Communications'
143     },
144     'tel095': {
145         'name': 'Beaver Creek Cooperative Telephone'
146     },
147     'bea020': {
148         'name': 'Beaver Valley Cable'
149     },
150     'bee010': {
151         'name': 'Bee Line Cable'
152     },
153     'wir030': {
154         'name': 'Beehive Broadband'
155     },
156     'bra020': {
157         'name': 'BELD'
158     },
159     'bel020': {
160         'name': 'Bellevue Municipal Cable'
161     },
162     'vol040-01': {
163         'name': 'Ben Lomand Connect / BLTV'
164     },
165     'bev010': {
166         'name': 'BEVCOMM'
167     },
168     'big020': {
169         'name': 'Big Sandy Broadband'
170     },
171     'ble020': {
172         'name': 'Bledsoe Telephone Cooperative'
173     },
174     'bvt010': {
175         'name': 'Blue Valley Tele-Communications'
176     },
177     'bra050': {
178         'name': 'Brandenburg Telephone Co.'
179     },
180     'bte010': {
181         'name': 'Bristol Tennessee Essential Services'
182     },
183     'annearundel': {
184         'name': 'Broadstripe'
185     },
186     'btc010': {
187         'name': 'BTC Communications'
188     },
189     'btc040': {
190         'name': 'BTC Vision - Nahunta'
191     },
192     'bul010': {
193         'name': 'Bulloch Telephone Cooperative'
194     },
195     'but010': {
196         'name': 'Butler-Bremer Communications'
197     },
198     'tel160-csp': {
199         'name': 'C Spire SNAP'
200     },
201     'csicable': {
202         'name': 'Cable Services Inc.'
203     },
204     'cableamerica': {
205         'name': 'CableAmerica'
206     },
207     'cab038': {
208         'name': 'CableSouth Media 3'
209     },
210     'weh010-camtel': {
211         'name': 'Cam-Tel Company'
212     },
213     'car030': {
214         'name': 'Cameron Communications'
215     },
216     'canbytel': {
217         'name': 'Canby Telcom'
218     },
219     'crt020': {
220         'name': 'CapRock Tv'
221     },
222     'car050': {
223         'name': 'Carnegie Cable'
224     },
225     'cas': {
226         'name': 'CAS Cable'
227     },
228     'casscomm': {
229         'name': 'CASSCOMM'
230     },
231     'mid180-02': {
232         'name': 'Catalina Broadband Solutions'
233     },
234     'cccomm': {
235         'name': 'CC Communications'
236     },
237     'nttccde010': {
238         'name': 'CDE Lightband'
239     },
240     'cfunet': {
241         'name': 'Cedar Falls Utilities'
242     },
243     'dem010-01': {
244         'name': 'Celect-Bloomer Telephone Area'
245     },
246     'dem010-02': {
247         'name': 'Celect-Bruce Telephone Area'
248     },
249     'dem010-03': {
250         'name': 'Celect-Citizens Connected Area'
251     },
252     'dem010-04': {
253         'name': 'Celect-Elmwood/Spring Valley Area'
254     },
255     'dem010-06': {
256         'name': 'Celect-Mosaic Telecom'
257     },
258     'dem010-05': {
259         'name': 'Celect-West WI Telephone Area'
260     },
261     'net010-02': {
262         'name': 'Cellcom/Nsight Telservices'
263     },
264     'cen100': {
265         'name': 'CentraCom'
266     },
267     'nttccst010': {
268         'name': 'Central Scott / CSTV'
269     },
270     'cha035': {
271         'name': 'Chaparral CableVision'
272     },
273     'cha050': {
274         'name': 'Chariton Valley Communication Corporation, Inc.'
275     },
276     'cha060': {
277         'name': 'Chatmoss Cablevision'
278     },
279     'nttcche010': {
280         'name': 'Cherokee Communications'
281     },
282     'che050': {
283         'name': 'Chesapeake Bay Communications'
284     },
285     'cimtel': {
286         'name': 'Cim-Tel Cable, LLC.'
287     },
288     'cit180': {
289         'name': 'Citizens Cablevision - Floyd, VA'
290     },
291     'cit210': {
292         'name': 'Citizens Cablevision, Inc.'
293     },
294     'cit040': {
295         'name': 'Citizens Fiber'
296     },
297     'cit250': {
298         'name': 'Citizens Mutual'
299     },
300     'war040': {
301         'name': 'Citizens Telephone Corporation'
302     },
303     'wat025': {
304         'name': 'City Of Monroe'
305     },
306     'wadsworth': {
307         'name': 'CityLink'
308     },
309     'nor100': {
310         'name': 'CL Tel'
311     },
312     'cla010': {
313         'name': 'Clarence Telephone and Cedar Communications'
314     },
315     'ser060': {
316         'name': 'Clear Choice Communications'
317     },
318     'tac020': {
319         'name': 'Click! Cable TV'
320     },
321     'war020': {
322         'name': 'CLICK1.NET'
323     },
324     'cml010': {
325         'name': 'CML Telephone Cooperative Association'
326     },
327     'cns': {
328         'name': 'CNS'
329     },
330     'com160': {
331         'name': 'Co-Mo Connect'
332     },
333     'coa020': {
334         'name': 'Coast Communications'
335     },
336     'coa030': {
337         'name': 'Coaxial Cable TV'
338     },
339     'mid055': {
340         'name': 'Cobalt TV (Mid-State Community TV)'
341     },
342     'col070': {
343         'name': 'Columbia Power & Water Systems'
344     },
345     'col080': {
346         'name': 'Columbus Telephone'
347     },
348     'nor105': {
349         'name': 'Communications 1 Cablevision, Inc.'
350     },
351     'com150': {
352         'name': 'Community Cable & Broadband'
353     },
354     'com020': {
355         'name': 'Community Communications Company'
356     },
357     'coy010': {
358         'name': 'commZoom'
359     },
360     'com025': {
361         'name': 'Complete Communication Services'
362     },
363     'cat020': {
364         'name': 'Comporium'
365     },
366     'com071': {
367         'name': 'ComSouth Telesys'
368     },
369     'consolidatedcable': {
370         'name': 'Consolidated'
371     },
372     'conwaycorp': {
373         'name': 'Conway Corporation'
374     },
375     'coo050': {
376         'name': 'Coon Valley Telecommunications Inc'
377     },
378     'coo080': {
379         'name': 'Cooperative Telephone Company'
380     },
381     'cpt010': {
382         'name': 'CP-TEL'
383     },
384     'cra010': {
385         'name': 'Craw-Kan Telephone'
386     },
387     'crestview': {
388         'name': 'Crestview Cable Communications'
389     },
390     'cross': {
391         'name': 'Cross TV'
392     },
393     'cro030': {
394         'name': 'Crosslake Communications'
395     },
396     'ctc040': {
397         'name': 'CTC - Brainerd MN'
398     },
399     'phe030': {
400         'name': 'CTV-Beam - East Alabama'
401     },
402     'cun010': {
403         'name': 'Cunningham Telephone & Cable'
404     },
405     'dpc010': {
406         'name': 'D & P Communications'
407     },
408     'dak030': {
409         'name': 'Dakota Central Telecommunications'
410     },
411     'nttcdel010': {
412         'name': 'Delcambre Telephone LLC'
413     },
414     'tel160-del': {
415         'name': 'Delta Telephone Company'
416     },
417     'sal040': {
418         'name': 'DiamondNet'
419     },
420     'ind060-dc': {
421         'name': 'Direct Communications'
422     },
423     'doy010': {
424         'name': 'Doylestown Cable TV'
425     },
426     'dic010': {
427         'name': 'DRN'
428     },
429     'dtc020': {
430         'name': 'DTC'
431     },
432     'dtc010': {
433         'name': 'DTC Cable (Delhi)'
434     },
435     'dum010': {
436         'name': 'Dumont Telephone Company'
437     },
438     'dun010': {
439         'name': 'Dunkerton Telephone Cooperative'
440     },
441     'cci010': {
442         'name': 'Duo County Telecom'
443     },
444     'eagle': {
445         'name': 'Eagle Communications'
446     },
447     'weh010-east': {
448         'name': 'East Arkansas Cable TV'
449     },
450     'eatel': {
451         'name': 'EATEL Video, LLC'
452     },
453     'ell010': {
454         'name': 'ECTA'
455     },
456     'emerytelcom': {
457         'name': 'Emery Telcom Video LLC'
458     },
459     'nor200': {
460         'name': 'Empire Access'
461     },
462     'endeavor': {
463         'name': 'Endeavor Communications'
464     },
465     'sun045': {
466         'name': 'Enhanced Telecommunications Corporation'
467     },
468     'mid030': {
469         'name': 'enTouch'
470     },
471     'epb020': {
472         'name': 'EPB Smartnet'
473     },
474     'jea010': {
475         'name': 'EPlus Broadband'
476     },
477     'com065': {
478         'name': 'ETC'
479     },
480     'ete010': {
481         'name': 'Etex Communications'
482     },
483     'fbc-tele': {
484         'name': 'F&B Communications'
485     },
486     'fal010': {
487         'name': 'Falcon Broadband'
488     },
489     'fam010': {
490         'name': 'FamilyView CableVision'
491     },
492     'far020': {
493         'name': 'Farmers Mutual Telephone Company'
494     },
495     'fay010': {
496         'name': 'Fayetteville Public Utilities'
497     },
498     'sal060': {
499         'name': 'fibrant'
500     },
501     'fid010': {
502         'name': 'Fidelity Communications'
503     },
504     'for030': {
505         'name': 'FJ Communications'
506     },
507     'fli020': {
508         'name': 'Flint River Communications'
509     },
510     'far030': {
511         'name': 'FMT - Jesup'
512     },
513     'foo010': {
514         'name': 'Foothills Communications'
515     },
516     'for080': {
517         'name': 'Forsyth CableNet'
518     },
519     'fbcomm': {
520         'name': 'Frankfort Plant Board'
521     },
522     'tel160-fra': {
523         'name': 'Franklin Telephone Company'
524     },
525     'nttcftc010': {
526         'name': 'FTC'
527     },
528     'fullchannel': {
529         'name': 'Full Channel, Inc.'
530     },
531     'gar040': {
532         'name': 'Gardonville Cooperative Telephone Association'
533     },
534     'gbt010': {
535         'name': 'GBT Communications, Inc.'
536     },
537     'tec010': {
538         'name': 'Genuine Telecom'
539     },
540     'clr010': {
541         'name': 'Giant Communications'
542     },
543     'gla010': {
544         'name': 'Glasgow EPB'
545     },
546     'gle010': {
547         'name': 'Glenwood Telecommunications'
548     },
549     'gra060': {
550         'name': 'GLW Broadband Inc.'
551     },
552     'goldenwest': {
553         'name': 'Golden West Cablevision'
554     },
555     'vis030': {
556         'name': 'Grantsburg Telcom'
557     },
558     'gpcom': {
559         'name': 'Great Plains Communications'
560     },
561     'gri010': {
562         'name': 'Gridley Cable Inc'
563     },
564     'hbc010': {
565         'name': 'H&B Cable Services'
566     },
567     'hae010': {
568         'name': 'Haefele TV Inc.'
569     },
570     'htc010': {
571         'name': 'Halstad Telephone Company'
572     },
573     'har005': {
574         'name': 'Harlan Municipal Utilities'
575     },
576     'har020': {
577         'name': 'Hart Communications'
578     },
579     'ced010': {
580         'name': 'Hartelco TV'
581     },
582     'hea040': {
583         'name': 'Heart of Iowa Communications Cooperative'
584     },
585     'htc020': {
586         'name': 'Hickory Telephone Company'
587     },
588     'nttchig010': {
589         'name': 'Highland Communication Services'
590     },
591     'hig030': {
592         'name': 'Highland Media'
593     },
594     'spc010': {
595         'name': 'Hilliary Communications'
596     },
597     'hin020': {
598         'name': 'Hinton CATV Co.'
599     },
600     'hometel': {
601         'name': 'HomeTel Entertainment, Inc.'
602     },
603     'hoodcanal': {
604         'name': 'Hood Canal Communications'
605     },
606     'weh010-hope': {
607         'name': 'Hope - Prescott Cable TV'
608     },
609     'horizoncable': {
610         'name': 'Horizon Cable TV, Inc.'
611     },
612     'hor040': {
613         'name': 'Horizon Chillicothe Telephone'
614     },
615     'htc030': {
616         'name': 'HTC Communications Co. - IL'
617     },
618     'htccomm': {
619         'name': 'HTC Communications, Inc. - IA'
620     },
621     'wal005': {
622         'name': 'Huxley Communications'
623     },
624     'imon': {
625         'name': 'ImOn Communications'
626     },
627     'ind040': {
628         'name': 'Independence Telecommunications'
629     },
630     'rrc010': {
631         'name': 'Inland Networks'
632     },
633     'stc020': {
634         'name': 'Innovative Cable TV St Croix'
635     },
636     'car100': {
637         'name': 'Innovative Cable TV St Thomas-St John'
638     },
639     'icc010': {
640         'name': 'Inside Connect Cable'
641     },
642     'int100': {
643         'name': 'Integra Telecom'
644     },
645     'int050': {
646         'name': 'Interstate Telecommunications Coop'
647     },
648     'irv010': {
649         'name': 'Irvine Cable'
650     },
651     'k2c010': {
652         'name': 'K2 Communications'
653     },
654     'kal010': {
655         'name': 'Kalida Telephone Company, Inc.'
656     },
657     'kal030': {
658         'name': 'Kalona Cooperative Telephone Company'
659     },
660     'kmt010': {
661         'name': 'KMTelecom'
662     },
663     'kpu010': {
664         'name': 'KPU Telecommunications'
665     },
666     'kuh010': {
667         'name': 'Kuhn Communications, Inc.'
668     },
669     'lak130': {
670         'name': 'Lakeland Communications'
671     },
672     'lan010': {
673         'name': 'Langco'
674     },
675     'lau020': {
676         'name': 'Laurel Highland Total Communications, Inc.'
677     },
678     'leh010': {
679         'name': 'Lehigh Valley Cooperative Telephone'
680     },
681     'bra010': {
682         'name': 'Limestone Cable/Bracken Cable'
683     },
684     'loc020': {
685         'name': 'LISCO'
686     },
687     'lit020': {
688         'name': 'Litestream'
689     },
690     'tel140': {
691         'name': 'LivCom'
692     },
693     'loc010': {
694         'name': 'LocalTel Communications'
695     },
696     'weh010-longview': {
697         'name': 'Longview - Kilgore Cable TV'
698     },
699     'lon030': {
700         'name': 'Lonsdale Video Ventures, LLC'
701     },
702     'lns010': {
703         'name': 'Lost Nation-Elwood Telephone Co.'
704     },
705     'nttclpc010': {
706         'name': 'LPC Connect'
707     },
708     'lumos': {
709         'name': 'Lumos Networks'
710     },
711     'madison': {
712         'name': 'Madison Communications'
713     },
714     'mad030': {
715         'name': 'Madison County Cable Inc.'
716     },
717     'nttcmah010': {
718         'name': 'Mahaska Communication Group'
719     },
720     'mar010': {
721         'name': 'Marne & Elk Horn Telephone Company'
722     },
723     'mcc040': {
724         'name': 'McClure Telephone Co.'
725     },
726     'mctv': {
727         'name': 'MCTV'
728     },
729     'merrimac': {
730         'name': 'Merrimac Communications Ltd.'
731     },
732     'metronet': {
733         'name': 'Metronet'
734     },
735     'mhtc': {
736         'name': 'MHTC'
737     },
738     'midhudson': {
739         'name': 'Mid-Hudson Cable'
740     },
741     'midrivers': {
742         'name': 'Mid-Rivers Communications'
743     },
744     'mid045': {
745         'name': 'Midstate Communications'
746     },
747     'mil080': {
748         'name': 'Milford Communications'
749     },
750     'min030': {
751         'name': 'MINET'
752     },
753     'nttcmin010': {
754         'name': 'Minford TV'
755     },
756     'san040-02': {
757         'name': 'Mitchell Telecom'
758     },
759     'mlg010': {
760         'name': 'MLGC'
761     },
762     'mon060': {
763         'name': 'Mon-Cre TVE'
764     },
765     'mou110': {
766         'name': 'Mountain Telephone'
767     },
768     'mou050': {
769         'name': 'Mountain Village Cable'
770     },
771     'mtacomm': {
772         'name': 'MTA Communications, LLC'
773     },
774     'mtc010': {
775         'name': 'MTC Cable'
776     },
777     'med040': {
778         'name': 'MTC Technologies'
779     },
780     'man060': {
781         'name': 'MTCC'
782     },
783     'mtc030': {
784         'name': 'MTCO Communications'
785     },
786     'mul050': {
787         'name': 'Mulberry Telecommunications'
788     },
789     'mur010': {
790         'name': 'Murray Electric System'
791     },
792     'musfiber': {
793         'name': 'MUS FiberNET'
794     },
795     'mpw': {
796         'name': 'Muscatine Power & Water'
797     },
798     'nttcsli010': {
799         'name': 'myEVTV.com'
800     },
801     'nor115': {
802         'name': 'NCC'
803     },
804     'nor260': {
805         'name': 'NDTC'
806     },
807     'nctc': {
808         'name': 'Nebraska Central Telecom, Inc.'
809     },
810     'nel020': {
811         'name': 'Nelsonville TV Cable'
812     },
813     'nem010': {
814         'name': 'Nemont'
815     },
816     'new075': {
817         'name': 'New Hope Telephone Cooperative'
818     },
819     'nor240': {
820         'name': 'NICP'
821     },
822     'cic010': {
823         'name': 'NineStar Connect'
824     },
825     'nktelco': {
826         'name': 'NKTelco'
827     },
828     'nortex': {
829         'name': 'Nortex Communications'
830     },
831     'nor140': {
832         'name': 'North Central Telephone Cooperative'
833     },
834     'nor030': {
835         'name': 'Northland Communications'
836     },
837     'nor075': {
838         'name': 'Northwest Communications'
839     },
840     'nor125': {
841         'name': 'Norwood Light Broadband'
842     },
843     'net010': {
844         'name': 'Nsight Telservices'
845     },
846     'dur010': {
847         'name': 'Ntec'
848     },
849     'nts010': {
850         'name': 'NTS Communications'
851     },
852     'new045': {
853         'name': 'NU-Telecom'
854     },
855     'nulink': {
856         'name': 'NuLink'
857     },
858     'jam030': {
859         'name': 'NVC'
860     },
861     'far035': {
862         'name': 'OmniTel Communications'
863     },
864     'onesource': {
865         'name': 'OneSource Communications'
866     },
867     'cit230': {
868         'name': 'Opelika Power Services'
869     },
870     'daltonutilities': {
871         'name': 'OptiLink'
872     },
873     'mid140': {
874         'name': 'OPTURA'
875     },
876     'ote010': {
877         'name': 'OTEC Communication Company'
878     },
879     'cci020': {
880         'name': 'Packerland Broadband'
881     },
882     'pan010': {
883         'name': 'Panora Telco/Guthrie Center Communications'
884     },
885     'otter': {
886         'name': 'Park Region Telephone & Otter Tail Telcom'
887     },
888     'mid050': {
889         'name': 'Partner Communications Cooperative'
890     },
891     'fib010': {
892         'name': 'Pathway'
893     },
894     'paulbunyan': {
895         'name': 'Paul Bunyan Communications'
896     },
897     'pem020': {
898         'name': 'Pembroke Telephone Company'
899     },
900     'mck010': {
901         'name': 'Peoples Rural Telephone Cooperative'
902     },
903     'pul010': {
904         'name': 'PES Energize'
905     },
906     'phi010': {
907         'name': 'Philippi Communications System'
908     },
909     'phonoscope': {
910         'name': 'Phonoscope Cable'
911     },
912     'pin070': {
913         'name': 'Pine Belt Communications, Inc.'
914     },
915     'weh010-pine': {
916         'name': 'Pine Bluff Cable TV'
917     },
918     'pin060': {
919         'name': 'Pineland Telephone Cooperative'
920     },
921     'cam010': {
922         'name': 'Pinpoint Communications'
923     },
924     'pio060': {
925         'name': 'Pioneer Broadband'
926     },
927     'pioncomm': {
928         'name': 'Pioneer Communications'
929     },
930     'pioneer': {
931         'name': 'Pioneer DTV'
932     },
933     'pla020': {
934         'name': 'Plant TiftNet, Inc.'
935     },
936     'par010': {
937         'name': 'PLWC'
938     },
939     'pro035': {
940         'name': 'PMT'
941     },
942     'vik011': {
943         'name': 'Polar Cablevision'
944     },
945     'pottawatomie': {
946         'name': 'Pottawatomie Telephone Co.'
947     },
948     'premiercomm': {
949         'name': 'Premier Communications'
950     },
951     'psc010': {
952         'name': 'PSC'
953     },
954     'pan020': {
955         'name': 'PTCI'
956     },
957     'qco010': {
958         'name': 'QCOL'
959     },
960     'qua010': {
961         'name': 'Quality Cablevision'
962     },
963     'rad010': {
964         'name': 'Radcliffe Telephone Company'
965     },
966     'car040': {
967         'name': 'Rainbow Communications'
968     },
969     'rai030': {
970         'name': 'Rainier Connect'
971     },
972     'ral010': {
973         'name': 'Ralls Technologies'
974     },
975     'rct010': {
976         'name': 'RC Technologies'
977     },
978     'red040': {
979         'name': 'Red River Communications'
980     },
981     'ree010': {
982         'name': 'Reedsburg Utility Commission'
983     },
984     'mol010': {
985         'name': 'Reliance Connects- Oregon'
986     },
987     'res020': {
988         'name': 'Reserve Telecommunications'
989     },
990     'weh010-resort': {
991         'name': 'Resort TV Cable'
992     },
993     'rld010': {
994         'name': 'Richland Grant Telephone Cooperative, Inc.'
995     },
996     'riv030': {
997         'name': 'River Valley Telecommunications Coop'
998     },
999     'rockportcable': {
1000         'name': 'Rock Port Cablevision'
1001     },
1002     'rsf010': {
1003         'name': 'RS Fiber'
1004     },
1005     'rtc': {
1006         'name': 'RTC Communication Corp'
1007     },
1008     'res040': {
1009         'name': 'RTC-Reservation Telephone Coop.'
1010     },
1011     'rte010': {
1012         'name': 'RTEC Communications'
1013     },
1014     'stc010': {
1015         'name': 'S&T'
1016     },
1017     'san020': {
1018         'name': 'San Bruno Cable TV'
1019     },
1020     'san040-01': {
1021         'name': 'Santel'
1022     },
1023     'sav010': {
1024         'name': 'SCI Broadband-Savage Communications Inc.'
1025     },
1026     'sco050': {
1027         'name': 'Scottsboro Electric Power Board'
1028     },
1029     'scr010': {
1030         'name': 'Scranton Telephone Company'
1031     },
1032     'selco': {
1033         'name': 'SELCO'
1034     },
1035     'she010': {
1036         'name': 'Shentel'
1037     },
1038     'she030': {
1039         'name': 'Sherwood Mutual Telephone Association, Inc.'
1040     },
1041     'ind060-ssc': {
1042         'name': 'Silver Star Communications'
1043     },
1044     'sjoberg': {
1045         'name': 'Sjoberg\'s Inc.'
1046     },
1047     'sou025': {
1048         'name': 'SKT'
1049     },
1050     'sky050': {
1051         'name': 'SkyBest TV'
1052     },
1053     'nttcsmi010': {
1054         'name': 'Smithville Communications'
1055     },
1056     'woo010': {
1057         'name': 'Solarus'
1058     },
1059     'sou075': {
1060         'name': 'South Central Rural Telephone Cooperative'
1061     },
1062     'sou065': {
1063         'name': 'South Holt Cablevision, Inc.'
1064     },
1065     'sou035': {
1066         'name': 'South Slope Cooperative Communications'
1067     },
1068     'spa020': {
1069         'name': 'Spanish Fork Community Network'
1070     },
1071     'spe010': {
1072         'name': 'Spencer Municipal Utilities'
1073     },
1074     'spi005': {
1075         'name': 'Spillway Communications, Inc.'
1076     },
1077     'srt010': {
1078         'name': 'SRT'
1079     },
1080     'cccsmc010': {
1081         'name': 'St. Maarten Cable TV'
1082     },
1083     'sta025': {
1084         'name': 'Star Communications'
1085     },
1086     'sco020': {
1087         'name': 'STE'
1088     },
1089     'uin010': {
1090         'name': 'STRATA Networks'
1091     },
1092     'sum010': {
1093         'name': 'Sumner Cable TV'
1094     },
1095     'pie010': {
1096         'name': 'Surry TV/PCSI TV'
1097     },
1098     'swa010': {
1099         'name': 'Swayzee Communications'
1100     },
1101     'sweetwater': {
1102         'name': 'Sweetwater Cable Television Co'
1103     },
1104     'weh010-talequah': {
1105         'name': 'Tahlequah Cable TV'
1106     },
1107     'tct': {
1108         'name': 'TCT'
1109     },
1110     'tel050': {
1111         'name': 'Tele-Media Company'
1112     },
1113     'com050': {
1114         'name': 'The Community Agency'
1115     },
1116     'thr020': {
1117         'name': 'Three River'
1118     },
1119     'cab140': {
1120         'name': 'Town & Country Technologies'
1121     },
1122     'tra010': {
1123         'name': 'Trans-Video'
1124     },
1125     'tre010': {
1126         'name': 'Trenton TV Cable Company'
1127     },
1128     'tcc': {
1129         'name': 'Tri County Communications Cooperative'
1130     },
1131     'tri025': {
1132         'name': 'TriCounty Telecom'
1133     },
1134     'tri110': {
1135         'name': 'TrioTel Communications, Inc.'
1136     },
1137     'tro010': {
1138         'name': 'Troy Cablevision, Inc.'
1139     },
1140     'tsc': {
1141         'name': 'TSC'
1142     },
1143     'cit220': {
1144         'name': 'Tullahoma Utilities Board'
1145     },
1146     'tvc030': {
1147         'name': 'TV Cable of Rensselaer'
1148     },
1149     'tvc015': {
1150         'name': 'TVC Cable'
1151     },
1152     'cab180': {
1153         'name': 'TVision'
1154     },
1155     'twi040': {
1156         'name': 'Twin Lakes'
1157     },
1158     'tvtinc': {
1159         'name': 'Twin Valley'
1160     },
1161     'uis010': {
1162         'name': 'Union Telephone Company'
1163     },
1164     'uni110': {
1165         'name': 'United Communications - TN'
1166     },
1167     'uni120': {
1168         'name': 'United Services'
1169     },
1170     'uss020': {
1171         'name': 'US Sonet'
1172     },
1173     'cab060': {
1174         'name': 'USA Communications'
1175     },
1176     'she005': {
1177         'name': 'USA Communications/Shellsburg, IA'
1178     },
1179     'val040': {
1180         'name': 'Valley TeleCom Group'
1181     },
1182     'val025': {
1183         'name': 'Valley Telecommunications'
1184     },
1185     'val030': {
1186         'name': 'Valparaiso Broadband'
1187     },
1188     'cla050': {
1189         'name': 'Vast Broadband'
1190     },
1191     'sul015': {
1192         'name': 'Venture Communications Cooperative, Inc.'
1193     },
1194     'ver025': {
1195         'name': 'Vernon Communications Co-op'
1196     },
1197     'weh010-vicksburg': {
1198         'name': 'Vicksburg Video'
1199     },
1200     'vis070': {
1201         'name': 'Vision Communications'
1202     },
1203     'volcanotel': {
1204         'name': 'Volcano Vision, Inc.'
1205     },
1206     'vol040-02': {
1207         'name': 'VolFirst / BLTV'
1208     },
1209     'ver070': {
1210         'name': 'VTel'
1211     },
1212     'nttcvtx010': {
1213         'name': 'VTX1'
1214     },
1215     'bci010-02': {
1216         'name': 'Vyve Broadband'
1217     },
1218     'wab020': {
1219         'name': 'Wabash Mutual Telephone'
1220     },
1221     'waitsfield': {
1222         'name': 'Waitsfield Cable'
1223     },
1224     'wal010': {
1225         'name': 'Walnut Communications'
1226     },
1227     'wavebroadband': {
1228         'name': 'Wave'
1229     },
1230     'wav030': {
1231         'name': 'Waverly Communications Utility'
1232     },
1233     'wbi010': {
1234         'name': 'WBI'
1235     },
1236     'web020': {
1237         'name': 'Webster-Calhoun Cooperative Telephone Association'
1238     },
1239     'wes005': {
1240         'name': 'West Alabama TV Cable'
1241     },
1242     'carolinata': {
1243         'name': 'West Carolina Communications'
1244     },
1245     'wct010': {
1246         'name': 'West Central Telephone Association'
1247     },
1248     'wes110': {
1249         'name': 'West River Cooperative Telephone Company'
1250     },
1251     'ani030': {
1252         'name': 'WesTel Systems'
1253     },
1254     'westianet': {
1255         'name': 'Western Iowa Networks'
1256     },
1257     'nttcwhi010': {
1258         'name': 'Whidbey Telecom'
1259     },
1260     'weh010-white': {
1261         'name': 'White County Cable TV'
1262     },
1263     'wes130': {
1264         'name': 'Wiatel'
1265     },
1266     'wik010': {
1267         'name': 'Wiktel'
1268     },
1269     'wil070': {
1270         'name': 'Wilkes Communications, Inc./RiverStreet Networks'
1271     },
1272     'wil015': {
1273         'name': 'Wilson Communications'
1274     },
1275     'win010': {
1276         'name': 'Windomnet/SMBS'
1277     },
1278     'win090': {
1279         'name': 'Windstream Cable TV'
1280     },
1281     'wcta': {
1282         'name': 'Winnebago Cooperative Telecom Association'
1283     },
1284     'wtc010': {
1285         'name': 'WTC'
1286     },
1287     'wil040': {
1288         'name': 'WTC Communications, Inc.'
1289     },
1290     'wya010': {
1291         'name': 'Wyandotte Cable'
1292     },
1293     'hin020-02': {
1294         'name': 'X-Stream Services'
1295     },
1296     'xit010': {
1297         'name': 'XIT Communications'
1298     },
1299     'yel010': {
1300         'name': 'Yelcot Communications'
1301     },
1302     'mid180-01': {
1303         'name': 'yondoo'
1304     },
1305     'cou060': {
1306         'name': 'Zito Media'
1307     },
1308 }
1309
1310
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'
1315
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)
1321
1322     @staticmethod
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>'
1336
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)
1341
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())
1345
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',
1356                 })
1357
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)
1363
1364         mvpd_headers = {
1365             'ap_42': 'anonymous',
1366             'ap_11': 'Linux i686',
1367             'ap_z': self._USER_AGENT,
1368             'User-Agent': self._USER_AGENT,
1369         }
1370
1371         guid = xml_text(resource, 'guid') if '<' in resource else resource
1372         count = 0
1373         while count < 2:
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'):
1377                 authn_token = None
1378             if not authn_token:
1379                 # TODO add support for other TV Providers
1380                 mso_id = self._downloader.params.get('ap_mso')
1381                 if not mso_id:
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]
1387
1388                 provider_redirect_page_res = self._download_webpage_handle(
1389                     self._SERVICE_PROVIDER_TEMPLATE % 'authenticate/saml', video_id,
1390                     'Downloading Provider Redirect Page', query={
1391                         'noflash': 'true',
1392                         'mso_id': mso_id,
1393                         'requestor_id': requestor_id,
1394                         'no_iframe': 'false',
1395                         'domain_name': 'adobe.com',
1396                         'redirect_url': url,
1397                     })
1398
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')
1409                     else:
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')
1419                         else:
1420                             provider_login_page_res = post_form(
1421                                 provider_redirect_page_res,
1422                                 'Downloading Provider Login Page')
1423
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,
1428                             })
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')
1444                     else:
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,
1449                             })
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']
1465                         }), headers={
1466                             'Content-Type': 'application/x-www-form-urlencoded'
1467                         })
1468                 else:
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,
1474                     })
1475                     if mso_id != 'Rogers':
1476                         post_form(mvpd_confirm_page_res, 'Confirming Login')
1477
1478                 session = self._download_webpage(
1479                     self._SERVICE_PROVIDER_TEMPLATE % 'session', video_id,
1480                     'Retrieving Session', data=urlencode_postdata({
1481                         '_method': 'GET',
1482                         'requestor_id': requestor_id,
1483                     }), headers=mvpd_headers)
1484                 if '<pendingLogout' in session:
1485                     self._downloader.cache.store(self._MVPD_CACHE, requestor_id, {})
1486                     count += 1
1487                     continue
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)
1491
1492             authz_token = requestor_info.get(guid)
1493             if authz_token and is_expired(authz_token, 'simpleTokenTTL'):
1494                 authz_token = None
1495             if not authz_token:
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'),
1503                         'userMeta': '1',
1504                     }), headers=mvpd_headers)
1505                 if '<pendingLogout' in authorize:
1506                     self._downloader.cache.store(self._MVPD_CACHE, requestor_id, {})
1507                     count += 1
1508                     continue
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)
1514
1515             mvpd_headers.update({
1516                 'ap_19': xml_text(authn_token, 'simpleSamlNameID'),
1517                 'ap_23': xml_text(authn_token, 'simpleSamlSessionIndex'),
1518             })
1519
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, {})
1530                 count += 1
1531                 continue
1532             return short_authorize