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