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