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