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