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