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