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