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