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