]>
Commit | Line | Data |
---|---|---|
1 | import base64 | |
2 | import hashlib | |
3 | import json | |
4 | import random | |
5 | import re | |
6 | import time | |
7 | ||
8 | from .common import InfoExtractor | |
9 | from ..aes import aes_encrypt | |
10 | from ..utils import ( | |
11 | bytes_to_intlist, | |
12 | determine_ext, | |
13 | int_or_none, | |
14 | intlist_to_bytes, | |
15 | join_nonempty, | |
16 | smuggle_url, | |
17 | strip_jsonp, | |
18 | traverse_obj, | |
19 | unescapeHTML, | |
20 | unsmuggle_url, | |
21 | ) | |
22 | ||
23 | ||
24 | def md5_text(s): | |
25 | return hashlib.md5(str(s).encode()).hexdigest() | |
26 | ||
27 | ||
28 | class AnvatoIE(InfoExtractor): | |
29 | _VALID_URL = r'anvato:(?P<access_key_or_mcp>[^:]+):(?P<id>\d+)' | |
30 | ||
31 | _API_BASE_URL = 'https://tkx.mp.lura.live/rest/v2' | |
32 | _ANVP_RE = r'<script[^>]+\bdata-anvp\s*=\s*(["\'])(?P<anvp>(?:(?!\1).)+)\1' | |
33 | _AUTH_KEY = b'\x31\xc2\x42\x84\x9e\x73\xa0\xce' # from anvplayer.min.js | |
34 | ||
35 | _TESTS = [{ | |
36 | # from https://www.nfl.com/videos/baker-mayfield-s-game-changing-plays-from-3-td-game-week-14 | |
37 | 'url': 'anvato:GXvEgwyJeWem8KCYXfeoHWknwP48Mboj:899441', | |
38 | 'md5': '921919dab3cd0b849ff3d624831ae3e2', | |
39 | 'info_dict': { | |
40 | 'id': '899441', | |
41 | 'ext': 'mp4', | |
42 | 'title': 'Baker Mayfield\'s game-changing plays from 3-TD game Week 14', | |
43 | 'description': 'md5:85e05a3cc163f8c344340f220521136d', | |
44 | 'upload_date': '20201215', | |
45 | 'timestamp': 1608009755, | |
46 | 'thumbnail': r're:^https?://.*\.jpg', | |
47 | 'uploader': 'NFL', | |
48 | 'tags': ['Baltimore Ravens at Cleveland Browns (2020-REG-14)', 'Baker Mayfield', 'Game Highlights', | |
49 | 'Player Highlights', 'Cleveland Browns', 'league'], | |
50 | 'duration': 157, | |
51 | 'categories': ['Entertainment', 'Game', 'Highlights'], | |
52 | }, | |
53 | }, { | |
54 | # from https://ktla.com/news/99-year-old-woman-learns-to-fly-in-torrance-checks-off-bucket-list-dream/ | |
55 | 'url': 'anvato:X8POa4zpGZMmeiq0wqiO8IP5rMqQM9VN:8032455', | |
56 | 'md5': '837718bcfb3a7778d022f857f7a9b19e', | |
57 | 'info_dict': { | |
58 | 'id': '8032455', | |
59 | 'ext': 'mp4', | |
60 | 'title': '99-year-old woman learns to fly plane in Torrance, checks off bucket list dream', | |
61 | 'description': 'md5:0a12bab8159445e78f52a297a35c6609', | |
62 | 'upload_date': '20220928', | |
63 | 'timestamp': 1664408881, | |
64 | 'thumbnail': r're:^https?://.*\.jpg', | |
65 | 'uploader': 'LIN', | |
66 | 'tags': ['video', 'news', '5live'], | |
67 | 'duration': 155, | |
68 | 'categories': ['News'], | |
69 | }, | |
70 | }] | |
71 | ||
72 | # Copied from anvplayer.min.js | |
73 | _ANVACK_TABLE = { | |
74 | 'nbcu_nbcd_desktop_web_prod_93d8ead38ce2024f8f544b78306fbd15895ae5e6': 'NNemUkySjxLyPTKvZRiGntBIjEyK8uqicjMakIaQ', | |
75 | 'nbcu_nbcd_desktop_web_qa_1a6f01bdd0dc45a439043b694c8a031d': 'eSxJUbA2UUKBTXryyQ2d6NuM8oEqaPySvaPzfKNA', | |
76 | 'nbcu_nbcd_desktop_web_acc_eb2ff240a5d4ae9a63d4c297c32716b6c523a129': '89JR3RtUGbvKuuJIiKOMK0SoarLb5MUx8v89RcbP', | |
77 | 'nbcu_nbcd_watchvod_web_prod_e61107507180976724ec8e8319fe24ba5b4b60e1': 'Uc7dFt7MJ9GsBWB5T7iPvLaMSOt8BBxv4hAXk5vv', | |
78 | 'nbcu_nbcd_watchvod_web_qa_42afedba88a36203db5a4c09a5ba29d045302232': 'T12oDYVFP2IaFvxkmYMy5dKxswpLHtGZa4ZAXEi7', | |
79 | 'nbcu_nbcd_watchvod_web_acc_9193214448e2e636b0ffb78abacfd9c4f937c6ca': 'MmobcxUxMedUpohNWwXaOnMjlbiyTOBLL6d46ZpR', | |
80 | 'nbcu_local_monitor_web_acc_f998ad54eaf26acd8ee033eb36f39a7b791c6335': 'QvfIoPYrwsjUCcASiw3AIkVtQob2LtJHfidp9iWg', | |
81 | 'nbcu_cable_monitor_web_acc_a413759603e8bedfcd3c61b14767796e17834077': 'uwVPJLShvJWSs6sWEIuVem7MTF8A4IknMMzIlFto', | |
82 | 'nbcu_nbcd_mcpstage_web_qa_4c43a8f6e95a88dbb40276c0630ba9f693a63a4e': 'PxVYZVwjhgd5TeoPRxL3whssb5OUPnM3zyAzq8GY', | |
83 | 'nbcu_comcast_comcast_web_prod_074080762ad4ce956b26b43fb22abf153443a8c4': 'afnaRZfDyg1Z3WZHdupKfy6xrbAG2MHqe3VfuSwh', | |
84 | 'nbcu_comcast_comcast_web_qa_706103bb93ead3ef70b1de12a0e95e3c4481ade0': 'DcjsVbX9b3uoPlhdriIiovgFQZVxpISZwz0cx1ZK', | |
85 | 'nbcu_comcast_comcastcable_web_prod_669f04817536743563d7331c9293e59fbdbe3d07': '0RwMN2cWy10qhAhOscq3eK7aEe0wqnKt3vJ0WS4D', | |
86 | 'nbcu_comcast_comcastcable_web_qa_3d9d2d66219094127f0f6b09cc3c7bb076e3e1ca': '2r8G9DEya7PCqBceKZgrn2XkXgASjwLMuaFE1Aad', | |
87 | 'hearst_hearst_demo_web_stage_960726dfef3337059a01a78816e43b29ec04dfc7': 'cuZBPXTR6kSdoTCVXwk5KGA8rk3NrgGn4H6e9Dsp', | |
88 | 'anvato_mcpqa_demo_web_stage_18b55e00db5a13faa8d03ae6e41f6f5bcb15b922': 'IOaaLQ8ymqVyem14QuAvE5SndQynTcH5CrLkU2Ih', | |
89 | 'anvato_nextmedia_demo_web_stage_9787d56a02ff6b9f43e9a2b0920d8ca88beb5818': 'Pqu9zVzI1ApiIzbVA3VkGBEQHvdKSUuKpD6s2uaR', | |
90 | 'anvato_scripps_app_web_prod_0837996dbe373629133857ae9eb72e740424d80a': 'du1ccmn7RxzgizwbWU7hyUaGodNlJn7HtXI0WgXW', | |
91 | 'anvato_scripps_app_web_stage_360797e00fe2826be142155c4618cc52fce6c26c': '2PMrQ0BRoqCWl7nzphj0GouIMEh2mZYivAT0S1Su', | |
92 | 'fs2go_fs2go_go_all_prod_21934911ccfafc03a075894ead2260d11e2ddd24': 'RcuHlKikW2IJw6HvVoEkqq2UsuEJlbEl11pWXs4Q', | |
93 | 'fs2go_fs2go_go_web_prod_ead4b0eec7460c1a07783808db21b49cf1f2f9a7': '4K0HTT2u1zkQA2MaGaZmkLa1BthGSBdr7jllrhk5', | |
94 | 'fs2go_fs2go_go_web_stage_407585454a4400355d4391691c67f361': 'ftnc37VKRJBmHfoGGi3kT05bHyeJzilEzhKJCyl3', | |
95 | 'fs2go_fs2go_go_android_stage_44b714db6f8477f29afcba15a41e1d30': 'CtxpPvVpo6AbZGomYUhkKs7juHZwNml9b9J0J2gI', | |
96 | 'anvato_cbslocal_app_web_prod_547f3e49241ef0e5d30c79b2efbca5d92c698f67': 'Pw0XX5KBDsyRnPS0R2JrSrXftsy8Jnz5pAjaYC8s', | |
97 | 'anvato_cbslocal_app_web_stage_547a5f096594cd3e00620c6f825cad1096d28c80': '37OBUhX2uwNyKhhrNzSSNHSRPZpApC3trdqDBpuz', | |
98 | 'fs2go_att_att_web_prod_1042dddd089a05438b6a08f972941176f699ffd8': 'JLcF20JwYvpv6uAGcLWIaV12jKwaL1R8us4b6Zkg', | |
99 | 'fs2go_att_att_web_stage_807c5001955fc114a3331fe027ddc76e': 'gbu1oO1y0JiOFh4SUipt86P288JHpyjSqolrrT1x', | |
100 | 'fs2go_fs2go_tudor_web_prod_a7dd8e5a7cdc830cae55eae6f3e9fee5ee49eb9b': 'ipcp87VCEZXPPe868j3orLqzc03oTy7DXsGkAXXH', | |
101 | 'anvato_mhz_app_web_prod_b808218b30de7fdf60340cbd9831512bc1bf6d37': 'Stlm5Gs6BEhJLRTZHcNquyzxGqr23EuFmE5DCgjX', | |
102 | 'fs2go_charter_charter_web_stage_c2c6e5a68375a1bf00fff213d3ff8f61a835a54c': 'Lz4hbJp1fwL6jlcz4M2PMzghM4jp4aAmybtT5dPc', | |
103 | 'fs2go_charter_charter_web_prod_ebfe3b10f1af215a7321cd3d629e0b81dfa6fa8c': 'vUJsK345A1bVmyYDRhZX0lqFIgVXuqhmuyp1EtPK', | |
104 | 'anvato_epfox_app_web_prod_b3373168e12f423f41504f207000188daf88251b': 'GDKq1ixvX3MoBNdU5IOYmYa2DTUXYOozPjrCJnW7', | |
105 | 'anvato_epfox_app_web_stage_a3c2ce60f8f83ef374a88b68ee73a950f8ab87ce': '2jz2NH4BsXMaDsoJ5qkHMbcczAfIReo2eFYuVC1C', | |
106 | 'fs2go_verizon_verizon_web_stage_08e6df0354a4803f1b1f2428b5a9a382e8dbcd62': 'rKTVapNaAcmnUbGL4ZcuOoY4SE7VmZSQsblPFr7e', | |
107 | 'fs2go_verizon_verizon_web_prod_f909564cb606eff1f731b5e22e0928676732c445': 'qLSUuHerM3u9eNPzaHyUK52obai5MvE4XDJfqYe1', | |
108 | 'fs2go_foxcom_synd_web_stage_f7b9091f00ea25a4fdaaae77fca5b54cdc7e7043': '96VKF2vLd24fFiDfwPFpzM5llFN4TiIGAlodE0Re', | |
109 | 'fs2go_foxcom_synd_web_prod_0f2cdd64d87e4ab6a1d54aada0ff7a7c8387a064': 'agiPjbXEyEZUkbuhcnmVPhe9NNVbDjCFq2xkcx51', | |
110 | 'anvato_own_app_web_stage_1214ade5d28422c4dae9d03c1243aba0563c4dba': 'mzhamNac3swG4WsJAiUTacnGIODi6SWeVWk5D7ho', | |
111 | 'anvato_own_app_web_prod_944e162ed927ec3e9ed13eb68ed2f1008ee7565e': '9TSxh6G2TXOLBoYm9ro3LdNjjvnXpKb8UR8KoIP9', | |
112 | 'anvato_scripps_app_ftv_prod_a10a10468edd5afb16fb48171c03b956176afad1': 'COJ2i2UIPK7xZqIWswxe7FaVBOVgRkP1F6O6qGoH', | |
113 | 'anvato_scripps_app_ftv_stage_77d3ad2bdb021ec37ca2e35eb09acd396a974c9a': 'Q7nnopNLe2PPfGLOTYBqxSaRpl209IhqaEuDZi1F', | |
114 | 'anvato_univision_app_web_stage_551236ef07a0e17718c3995c35586b5ed8cb5031': 'D92PoLS6UitwxDRA191HUGT9OYcOjV6mPMa5wNyo', | |
115 | 'anvato_univision_app_web_prod_039a5c0a6009e637ae8ac906718a79911e0e65e1': '5mVS5u4SQjtw6NGw2uhMbKEIONIiLqRKck5RwQLR', | |
116 | 'nbcu_cnbc_springfield_ios_prod_670207fae43d6e9a94c351688851a2ce': 'M7fqCCIP9lW53oJbHs19OlJlpDrVyc2OL8gNeuTa', | |
117 | 'nbcu_cnbc_springfieldvod_ios_prod_7a5f04b1ceceb0e9c9e2264a44aa236e08e034c2': 'Yia6QbJahW0S7K1I0drksimhZb4UFq92xLBmmMvk', | |
118 | 'anvato_cox_app_web_prod_ce45cda237969f93e7130f50ee8bb6280c1484ab': 'cc0miZexpFtdoqZGvdhfXsLy7FXjRAOgb9V0f5fZ', | |
119 | 'anvato_cox_app_web_stage_c23dbe016a8e9d8c7101d10172b92434f6088bf9': 'yivU3MYHd2eDZcOfmLbINVtqxyecKTOp8OjOuoGJ', | |
120 | 'anvato_chnzero_app_web_stage_b1164d1352b579e792e542fddf13ee34c0eeb46b': 'A76QkXMmVH8lTCfU15xva1mZnSVcqeY4Xb22Kp7m', | |
121 | 'anvato_chnzero_app_web_prod_253d358928dc08ec161eda2389d53707288a730c': 'OA5QI3ZWZZkdtUEDqh28AH8GedsF6FqzJI32596b', | |
122 | 'anvato_discovery_vodpoc_web_stage_9fa7077b5e8af1f8355f65d4fb8d2e0e9d54e2b7': 'q3oT191tTQ5g3JCP67PkjLASI9s16DuWZ6fYmry3', | |
123 | 'anvato_discovery_vodpoc_web_prod_688614983167a1af6cdf6d76343fda10a65223c1': 'qRvRQCTVHd0VVOHsMvvfidyWmlYVrTbjby7WqIuK', | |
124 | 'nbcu_cnbc_springfieldvod_ftv_stage_826040aad1925a46ac5dfb4b3c5143e648c6a30d': 'JQaSb5a8Tz0PT4ti329DNmzDO30TnngTHmvX8Vua', | |
125 | 'nbcu_cnbc_springfield_ftv_stage_826040aad1925a46ac5dfb4b3c5143e648c6a30d': 'JQaSb5a8Tz0PT4ti329DNmzDO30TnngTHmvX8Vua', | |
126 | 'nbcu_nbcd_capture_web_stage_4dd9d585bfb984ebf856dee35db027b2465cc4ae': '0j1Ov4Vopyi2HpBZJYdL2m8ERJVGYh3nNpzPiO8F', | |
127 | 'nbcu_nbcd_watch3_android_prod_7712ca5fcf1c22f19ec1870a9650f9c37db22dcf': '3LN2UB3rPUAMu7ZriWkHky9vpLMXYha8JbSnxBlx', | |
128 | 'nbcu_nbcd_watchvod3_android_prod_0910a3a4692d57c0b5ff4316075bc5d096be45b9': 'mJagcQ2II30vUOAauOXne7ERwbf5S9nlB3IP17lQ', | |
129 | 'anvato_scripps_app_atv_prod_790deda22e16e71e83df58f880cd389908a45d52': 'CB6trI1mpoDIM5o54DNTsji90NDBQPZ4z4RqBNSH', | |
130 | 'nbcu_nbcd_watchv4_android_prod_ff67cef9cb409158c6f8c3533edddadd0b750507': 'j8CHQCUWjlYERj4NFRmUYOND85QNbHViH09UwuKm', | |
131 | 'nbcu_nbcd_watchvodv4_android_prod_a814d781609989dea6a629d50ae4c7ad8cc8e907': 'rkVnUXxdA9rawVLUlDQtMue9Y4Q7lFEaIotcUhjt', | |
132 | 'rvVKpA50qlOPLFxMjrCGf5pdkdQDm7qn': '1J7ZkY5Qz5lMLi93QOH9IveE7EYB3rLl', | |
133 | 'nbcu_dtv_local_web_prod_b266cf49defe255fd4426a97e27c09e513e9f82f': 'HuLnJDqzLa4saCzYMJ79zDRSQpEduw1TzjMNQu2b', | |
134 | 'nbcu_att_local_web_prod_4cef038b2d969a6b7d700a56a599040b6a619f67': 'Q0Em5VDc2KpydUrVwzWRXAwoNBulWUxCq2faK0AV', | |
135 | 'nbcu_dish_local_web_prod_c56dcaf2da2e9157a4266c82a78195f1dd570f6b': 'bC1LWmRz9ayj2AlzizeJ1HuhTfIaJGsDBnZNgoRg', | |
136 | 'nbcu_verizon_local_web_prod_88bebd2ce006d4ed980de8133496f9a74cb9b3e1': 'wzhDKJZpgvUSS1EQvpCQP8Q59qVzcPixqDGJefSk', | |
137 | 'nbcu_charter_local_web_prod_9ad90f7fc4023643bb718f0fe0fd5beea2382a50': 'PyNbxNhEWLzy1ZvWEQelRuIQY88Eub7xbSVRMdfT', | |
138 | 'nbcu_suddenlink_local_web_prod_20fb711725cac224baa1c1cb0b1c324d25e97178': '0Rph41lPXZbb3fqeXtHjjbxfSrNbtZp1Ygq7Jypa', | |
139 | 'nbcu_wow_local_web_prod_652d9ce4f552d9c2e7b5b1ed37b8cb48155174ad': 'qayIBZ70w1dItm2zS42AptXnxW15mkjRrwnBjMPv', | |
140 | 'nbcu_centurylink_local_web_prod_2034402b029bf3e837ad46814d9e4b1d1345ccd5': 'StePcPMkjsX51PcizLdLRMzxMEl5k2FlsMLUNV4k', | |
141 | 'nbcu_atlanticbrd_local_web_prod_8d5f5ecbf7f7b2f5e6d908dd75d90ae3565f682e': 'NtYLb4TFUS0pRs3XTkyO5sbVGYjVf17bVbjaGscI', | |
142 | 'nbcu_nbcd_watchvod_web_dev_08bc05699be47c4f31d5080263a8cfadc16d0f7c': 'hwxi2dgDoSWgfmVVXOYZm14uuvku4QfopstXckhr', | |
143 | 'anvato_nextmedia_app_web_prod_a4fa8c7204aa65e71044b57aaf63711980cfe5a0': 'tQN1oGPYY1nM85rJYePWGcIb92TG0gSqoVpQTWOw', | |
144 | 'anvato_mcp_lin_web_prod_4c36fbfd4d8d8ecae6488656e21ac6d1ac972749': 'GUXNf5ZDX2jFUpu4WT2Go4DJ5nhUCzpnwDRRUx1K', | |
145 | 'anvato_mcp_univision_web_prod_37fe34850c99a3b5cdb71dab10a417dd5cdecafa': 'bLDYF8JqfG42b7bwKEgQiU9E2LTIAtnKzSgYpFUH', | |
146 | 'anvato_mcp_fs2go_web_prod_c7b90a93e171469cdca00a931211a2f556370d0a': 'icgGoYGipQMMSEvhplZX1pwbN69srwKYWksz3xWK', | |
147 | 'anvato_mcp_sps_web_prod_54bdc90dd6ba21710e9f7074338365bba28da336': 'fA2iQdI7RDpynqzQYIpXALVS83NTPr8LLFK4LFsu', | |
148 | 'anvato_mcp_anv_web_prod_791407490f4c1ef2a4bcb21103e0cb1bcb3352b3': 'rMOUZqe9lwcGq2mNgG3EDusm6lKgsUnczoOX3mbg', | |
149 | 'anvato_mcp_gray_web_prod_4c10f067c393ed8fc453d3930f8ab2b159973900': 'rMOUZqe9lwcGq2mNgG3EDusm6lKgsUnczoOX3mbg', | |
150 | 'anvato_mcp_hearst_web_prod_5356c3de0fc7c90a3727b4863ca7fec3a4524a99': 'P3uXJ0fXXditBPCGkfvlnVScpPEfKmc64Zv7ZgbK', | |
151 | 'anvato_mcp_cbs_web_prod_02f26581ff80e5bda7aad28226a8d369037f2cbe': 'mGPvo5ZA5SgjOFAPEPXv7AnOpFUICX8hvFQVz69n', | |
152 | 'anvato_mcp_telemundo_web_prod_c5278d51ad46fda4b6ca3d0ea44a7846a054f582': 'qyT6PXXLjVNCrHaRVj0ugAhalNRS7Ee9BP7LUokD', | |
153 | 'nbcu_nbcd_watchvodv4_web_stage_4108362fba2d4ede21f262fea3c4162cbafd66c7': 'DhaU5lj0W2gEdcSSsnxURq8t7KIWtJfD966crVDk', | |
154 | 'anvato_scripps_app_ios_prod_409c41960c60b308db43c3cc1da79cab9f1c3d93': 'WPxj5GraLTkYCyj3M7RozLqIycjrXOEcDGFMIJPn', | |
155 | 'EZqvRyKBJLrgpClDPDF8I7Xpdp40Vx73': '4OxGd2dEakylntVKjKF0UK9PDPYB6A9W', | |
156 | 'M2v78QkpleXm9hPp9jUXI63x5vA6BogR': 'ka6K32k7ZALmpINkjJUGUo0OE42Md1BQ', | |
157 | 'nbcu_nbcd_desktop_web_prod_93d8ead38ce2024f8f544b78306fbd15895ae5e6_secure': 'NNemUkySjxLyPTKvZRiGntBIjEyK8uqicjMakIaQ', | |
158 | 'X8POa4zPPaKVZHqmWjuEzfP31b1QM9VN': 'Dn5vOY9ooDw7VSl9qztjZI5o0g08mA0z', | |
159 | 'M2v78QkBMpNJlSPp9diX5F2PBmBy6Bog': 'ka6K32kyo7nDZfNkjQCGWf1lpApXMd1B', | |
160 | 'bvJ0dQpav07l0hG5JgfVLF2dv1vARwpP': 'BzoQW24GrJZoJfmNodiJKSPeB9B8NOxj', | |
161 | 'lxQMLg2XZKuEZaWgsqubBxV9INZ6bryY': 'Vm2Mx6noKds9jB71h6urazwlTG3m9x8l', | |
162 | '04EnjvXeoSmkbJ9ckPs7oY0mcxv7PlyN': 'aXERQP9LMfQVlEDsgGs6eEA1SWznAQ8P', | |
163 | 'mQbO2ge6BFRWVPYCYpU06YvNt80XLvAX': 'E2BV1NGmasN5v7eujECVPJgwflnLPm2A', | |
164 | 'g43oeBzJrCml7o6fa5fRL1ErCdeD8z4K': 'RX34mZ6zVH4Nr6whbxIGLv9WSbxEKo8V', | |
165 | 'VQrDJoP7mtdBzkxhXbSPwGB1coeElk4x': 'j2VejQx0VFKQepAF7dI0mJLKtOVJE18z', | |
166 | 'WxA5NzLRjCrmq0NUgaU5pdMDuZO7RJ4w': 'lyY5ADLKaIOLEgAsGQCveEMAcqnx3rY9', | |
167 | 'M4lpMXB71ie0PjMCjdFzVXq0SeRVqz49': 'n2zVkOqaLIv3GbLfBjcwW51LcveWOZ2e', | |
168 | 'dyDZGEqN8u8nkJZcJns0oxYmtP7KbGAn': 'VXOEqQW9BtEVLajfZQSLEqxgS5B7qn2D', | |
169 | 'E7QNjrVY5u5mGvgu67IoDgV1CjEND8QR': 'rz8AaDmdKIkLmPNhB5ILPJnjS5PnlL8d', | |
170 | 'a4zrqjoKlfzg0dwHEWtP31VqcLBpjm4g': 'LY9J16gwETdGWa3hjBu5o0RzuoQDjqXQ', | |
171 | 'dQP5BZroMsMVLO1hbmT5r2Enu86GjxA6': '7XR3oOdbPF6x3PRFLDCq9RkgsRjAo48V', | |
172 | 'M4lKNBO1NFe0PjMCj1tzVXq0SeRVqzA9': 'n2zoRqGLRUv3GbLfBmTwW51LcveWOZYe', | |
173 | 'nAZ7MZdpGCGg1pqFEbsoJOz2C60mv143': 'dYJgdqA9aT4yojETqGi7yNgoFADxqmXP', | |
174 | '3y1MERYgOuE9NzbFgwhV6Wv2F0YKvbyz': '081xpZDQgC4VadLTavhWQxrku56DAgXV', | |
175 | 'bmQvmEXr5HWklBMCZOcpE2Z3HBYwqGyl': 'zxXPbVNyMiMAZldhr9FkOmA0fl4aKr2v', | |
176 | 'wA7oDNYldfr6050Hwxi52lPZiVlB86Ap': 'ZYK16aA7ni0d3l3c34uwpxD7CbReMm8Q', | |
177 | 'g43MbKMWmFml7o7sJoSRkXxZiXRvJ3QK': 'RX3oBJonvs4Nr6rUWBCGn3matRGqJPXV', | |
178 | 'mA9VdlqpLS0raGaSDvtoqNrBTzb8XY4q': '0XN4OjBD3fnW7r7IbmtJB4AyfOmlrE2r', | |
179 | 'mAajOwgkGt17oGoFmEuklMP9H0GnW54d': 'lXbBLPGyzikNGeGujAuAJGjZiwLRxyXR', | |
180 | 'vy8vjJ9kbUwrRqRu59Cj5dWZfzYErlAb': 'K8l7gpwaGcBpnAnCLNCmPZRdin3eaQX0', | |
181 | 'xQMWBpR8oHEZaWaSMGUb0avOHjLVYn4Y': 'm2MrN4vEaf9jB7BFy5Srb40jTrN67AYl', | |
182 | 'xyKEmVO3miRr6D6UVkt7oB8jtD6aJEAv': 'g2ddDebqDfqdgKgswyUKwGjbTWwzq923', | |
183 | '7Qk0wa2D9FjKapacoJF27aLvUDKkLGA0': 'b2kgBEkephJaMkMTL7s1PLe4Ua6WyP2P', | |
184 | '3QLg6nqmNTJ5VvVTo7f508LPidz1xwyY': 'g2L1GgpraipmAOAUqmIbBnPxHOmw4MYa', | |
185 | '3y1B7zZjXTE9NZNSzZSVNPZaTNLjo6Qz': '081b5G6wzH4VagaURmcWbN5mT4JGEe2V', | |
186 | 'lAqnwvkw6SG6D8DSqmUg6DRLUp0w3G4x': 'O2pbP0xPDFNJjpjIEvcdryOJtpkVM4X5', | |
187 | 'awA7xd1N0Hr6050Hw2c52lPZiVlB864p': 'GZYKpn4aoT0d3l3c3PiwpxD7CbReMmXQ', | |
188 | 'jQVqPLl9YHL1WGWtR1HDgWBGT63qRNyV': '6X03ne6vrU4oWyWUN7tQVoajikxJR3Ye', | |
189 | 'GQRMR8mL7uZK797t7xH3eNzPIP5dOny1': 'm2vqPWGd4U31zWzSyasDRAoMT1PKRp8o', | |
190 | 'zydq9RdmRhXLkNkfNoTJlMzaF0lWekQB': '3X7LnvE7vH5nkEkSqLiey793Un7dLB8e', | |
191 | 'VQrDzwkB2IdBzjzu9MHPbEYkSB50gR4x': 'j2VebLzoKUKQeEesmVh0gM1eIp9jKz8z', | |
192 | 'mAa2wMamBs17oGoFmktklMP9H0GnW54d': 'lXbgP74xZTkNGeGujVUAJGjZiwLRxy8R', | |
193 | '7yjB6ZLG6sW8R6RF2xcan1KGfJ5dNoyd': 'wXQkPorvPHZ45N5t4Jf6qwg5Tp4xvw29', | |
194 | 'a4zPpNeWGuzg0m0iX3tPeanGSkRKWXQg': 'LY9oa3QAyHdGW9Wu3Ri5JGeEik7l1N8Q', | |
195 | 'k2rneA2M38k25cXDwwSknTJlxPxQLZ6M': '61lyA2aEVDzklfdwmmh31saPxQx2VRjp', | |
196 | 'bK9Zk4OvPnvxduLgxvi8VUeojnjA02eV': 'o5jANYjbeMb4nfBaQvcLAt1jzLzYx6ze', | |
197 | '5VD6EydM3R9orHmNMGInGCJwbxbQvGRw': 'w3zjmX7g4vnxzCxElvUEOiewkokXprkZ', | |
198 | '70X35QbVYVYNPUmP9YfbzI06YqYQk2R1': 'vG4Aj2BMjMjoztB7zeFOnCVPJpJ8lMOa', | |
199 | '26qYwQVG9p1Bks2GgBckjfDJOXOAMgG1': 'r4ev9X0mv5zqJc0yk5IBDcQOwZw8mnwQ', | |
200 | 'rvVKpA56MBXWlSxMw3cobT5pdkd4Dm7q': '1J7ZkY53pZ645c93owcLZuveE7E8B3rL', | |
201 | 'qN1zdy1zlYL23IWZGWtDvfV6WeWQWkJo': 'qN1zdy1zlYL23IWZGWtDvfV6WeWQWkJo', | |
202 | 'jdKqRGF16dKsBviMDae7IGDl7oTjEbVV': 'Q09l7vhlNxPFErIOK6BVCe7KnwUW5DVV', | |
203 | '3QLkogW1OUJ5VvPsrDH56DY2u7lgZWyY': 'g2LRE1V9espmAOPhE4ubj4ZdUA57yDXa', | |
204 | 'wyJvWbXGBSdbkEzhv0CW8meou82aqRy8': 'M2wolPvyBIpQGkbT4juedD4ruzQGdK2y', | |
205 | '7QkdZrzEkFjKap6IYDU2PB0oCNZORmA0': 'b2kN1l96qhJaMkPs9dt1lpjBfwqZoA8P', | |
206 | 'pvA05113MHG1w3JTYxc6DVlRCjErVz4O': 'gQXeAbblBUnDJ7vujbHvbRd1cxlz3AXO', | |
207 | 'mA9blJDZwT0raG1cvkuoeVjLC7ZWd54q': '0XN9jRPwMHnW7rvumgfJZOD9CJgVkWYr', | |
208 | '5QwRN5qKJTvGKlDTmnf7xwNZcjRmvEy9': 'R2GP6LWBJU1QlnytwGt0B9pytWwAdDYy', | |
209 | 'eyn5rPPbkfw2KYxH32fG1q58CbLJzM40': 'p2gyqooZnS56JWeiDgfmOy1VugOQEBXn', | |
210 | '3BABn3b5RfPJGDwilbHe7l82uBoR05Am': '7OYZG7KMVhbPdKJS3xcWEN3AuDlLNmXj', | |
211 | 'xA5zNGXD3HrmqMlF6OS5pdMDuZO7RJ4w': 'yY5DAm6r1IOLE3BCVMFveEMAcqnx3r29', | |
212 | 'g43PgW3JZfml7o6fDEURL1ErCdeD8zyK': 'RX3aQn1zrS4Nr6whDgCGLv9WSbxEKo2V', | |
213 | 'lAqp8WbGgiG6D8LTKJcg3O72CDdre1Qx': 'O2pnm6473HNJjpKuVosd3vVeh975yrX5', | |
214 | 'wyJbYEDxKSdbkJ6S6RhW8meou82aqRy8': 'M2wPm7EgRSpQGlAh70CedD4ruzQGdKYy', | |
215 | 'M4lgW28nLCe0PVdtaXszVXq0SeRVqzA9': 'n2zmJvg4jHv3G0ETNgiwW51LcveWOZ8e', | |
216 | '5Qw3OVvp9FvGKlDTmOC7xwNZcjRmvEQ9': 'R2GzDdml9F1Qlnytw9s0B9pytWwAdD8y', | |
217 | 'vy8a98X7zCwrRqbHrLUjYzwDiK2b70Qb': 'K8lVwzyjZiBpnAaSGeUmnAgxuGOBxmY0', | |
218 | 'g4eGjJLLoiqRD3Pf9oT5O03LuNbLRDQp': '6XqD59zzpfN4EwQuaGt67qNpSyRBlnYy', | |
219 | 'g43OPp9boIml7o6fDOIRL1ErCdeD8z4K': 'RX33alNB4s4Nr6whDPUGLv9WSbxEKoXV', | |
220 | 'xA2ng9OkBcGKzDbTkKsJlx7dUK8R3dA5': 'z2aPnJvzBfObkwGC3vFaPxeBhxoMqZ8K', | |
221 | 'xyKEgBajZuRr6DEC0Kt7XpD1cnNW9gAv': 'g2ddlEBvRsqdgKaI4jUK9PrgfMexGZ23', | |
222 | 'BAogww51jIMa2JnH1BcYpXM5F658RNAL': 'rYWDmm0KptlkGv4FGJFMdZmjs9RDE6XR', | |
223 | 'BAokpg62VtMa2JnH1mHYpXM5F658RNAL': 'rYWryDnlNslkGv4FG4HMdZmjs9RDE62R', | |
224 | 'a4z1Px5e2hzg0m0iMMCPeanGSkRKWXAg': 'LY9eorNQGUdGW9WuKKf5JGeEik7l1NYQ', | |
225 | 'kAx69R58kF9nY5YcdecJdl2pFXP53WyX': 'gXyRxELpbfPvLeLSaRil0mp6UEzbZJ8L', | |
226 | 'BAoY13nwViMa2J2uo2cY6BlETgmdwryL': 'rYWwKzJmNFlkGvGtNoUM9bzwIJVzB1YR', | |
227 | } | |
228 | ||
229 | _MCP_TO_ACCESS_KEY_TABLE = { | |
230 | 'qa': 'anvato_mcpqa_demo_web_stage_18b55e00db5a13faa8d03ae6e41f6f5bcb15b922', | |
231 | 'lin': 'anvato_mcp_lin_web_prod_4c36fbfd4d8d8ecae6488656e21ac6d1ac972749', | |
232 | 'univison': 'anvato_mcp_univision_web_prod_37fe34850c99a3b5cdb71dab10a417dd5cdecafa', | |
233 | 'uni': 'anvato_mcp_univision_web_prod_37fe34850c99a3b5cdb71dab10a417dd5cdecafa', | |
234 | 'dev': 'anvato_mcp_fs2go_web_prod_c7b90a93e171469cdca00a931211a2f556370d0a', | |
235 | 'sps': 'anvato_mcp_sps_web_prod_54bdc90dd6ba21710e9f7074338365bba28da336', | |
236 | 'spsstg': 'anvato_mcp_sps_web_prod_54bdc90dd6ba21710e9f7074338365bba28da336', | |
237 | 'anv': 'anvato_mcp_anv_web_prod_791407490f4c1ef2a4bcb21103e0cb1bcb3352b3', | |
238 | 'gray': 'anvato_mcp_gray_web_prod_4c10f067c393ed8fc453d3930f8ab2b159973900', | |
239 | 'hearst': 'anvato_mcp_hearst_web_prod_5356c3de0fc7c90a3727b4863ca7fec3a4524a99', | |
240 | 'cbs': 'anvato_mcp_cbs_web_prod_02f26581ff80e5bda7aad28226a8d369037f2cbe', | |
241 | 'telemundo': 'anvato_mcp_telemundo_web_prod_c5278d51ad46fda4b6ca3d0ea44a7846a054f582', | |
242 | } | |
243 | ||
244 | def _generate_nfl_token(self, anvack, mcp_id): | |
245 | reroute = self._download_json( | |
246 | 'https://api.nfl.com/v1/reroute', mcp_id, data=b'grant_type=client_credentials', | |
247 | headers={'X-Domain-Id': 100}, note='Fetching token info') | |
248 | token_type = reroute.get('token_type') or 'Bearer' | |
249 | auth_token = f'{token_type} {reroute["access_token"]}' | |
250 | response = self._download_json( | |
251 | 'https://api.nfl.com/v3/shield/', mcp_id, data=json.dumps({ | |
252 | 'query': '''{ | |
253 | viewer { | |
254 | mediaToken(anvack: "%s", id: %s) { | |
255 | token | |
256 | } | |
257 | } | |
258 | }''' % (anvack, mcp_id), # noqa: UP031 | |
259 | }).encode(), headers={ | |
260 | 'Authorization': auth_token, | |
261 | 'Content-Type': 'application/json', | |
262 | }, note='Fetching NFL API token') | |
263 | return traverse_obj(response, ('data', 'viewer', 'mediaToken', 'token')) | |
264 | ||
265 | _TOKEN_GENERATORS = { | |
266 | 'GXvEgwyJeWem8KCYXfeoHWknwP48Mboj': _generate_nfl_token, | |
267 | } | |
268 | ||
269 | def _server_time(self, access_key, video_id): | |
270 | return int_or_none(traverse_obj(self._download_json( | |
271 | f'{self._API_BASE_URL}/server_time', video_id, query={'anvack': access_key}, | |
272 | note='Fetching server time', fatal=False), 'server_time')) or int(time.time()) | |
273 | ||
274 | def _get_video_json(self, access_key, video_id, extracted_token): | |
275 | # See et() in anvplayer.min.js, which is an alias of getVideoJSON() | |
276 | video_data_url = f'{self._API_BASE_URL}/mcp/video/{video_id}?anvack={access_key}' | |
277 | server_time = self._server_time(access_key, video_id) | |
278 | input_data = f'{server_time}~{md5_text(video_data_url)}~{md5_text(server_time)}' | |
279 | ||
280 | auth_secret = intlist_to_bytes(aes_encrypt( | |
281 | bytes_to_intlist(input_data[:64]), bytes_to_intlist(self._AUTH_KEY))) | |
282 | query = { | |
283 | 'X-Anvato-Adst-Auth': base64.b64encode(auth_secret).decode('ascii'), | |
284 | 'rtyp': 'fp', | |
285 | } | |
286 | anvrid = md5_text(time.time() * 1000 * random.random())[:30] | |
287 | api = { | |
288 | 'anvrid': anvrid, | |
289 | 'anvts': server_time, | |
290 | } | |
291 | if extracted_token is not None: | |
292 | api['anvstk2'] = extracted_token | |
293 | elif self._TOKEN_GENERATORS.get(access_key) is not None: | |
294 | api['anvstk2'] = self._TOKEN_GENERATORS[access_key](self, access_key, video_id) | |
295 | elif self._ANVACK_TABLE.get(access_key) is not None: | |
296 | api['anvstk'] = md5_text(f'{access_key}|{anvrid}|{server_time}|{self._ANVACK_TABLE[access_key]}') | |
297 | else: | |
298 | api['anvstk2'] = 'default' | |
299 | ||
300 | return self._download_json( | |
301 | video_data_url, video_id, transform_source=strip_jsonp, query=query, | |
302 | data=json.dumps({'api': api}, separators=(',', ':')).encode()) | |
303 | ||
304 | def _get_anvato_videos(self, access_key, video_id, token): | |
305 | video_data = self._get_video_json(access_key, video_id, token) | |
306 | ||
307 | formats = [] | |
308 | for published_url in video_data['published_urls']: | |
309 | video_url = published_url.get('embed_url') | |
310 | if not video_url: | |
311 | continue | |
312 | media_format = published_url.get('format') | |
313 | ext = determine_ext(video_url) | |
314 | ||
315 | if ext == 'smil' or media_format == 'smil': | |
316 | formats.extend(self._extract_smil_formats(video_url, video_id)) | |
317 | continue | |
318 | ||
319 | tbr = int_or_none(published_url.get('kbps')) | |
320 | a_format = { | |
321 | 'url': video_url, | |
322 | 'format_id': join_nonempty('http', published_url.get('cdn_name')).lower(), | |
323 | 'tbr': tbr or None, | |
324 | } | |
325 | ||
326 | vtt_subs, hls_subs = {}, {} | |
327 | if media_format == 'vtt': | |
328 | _, vtt_subs = self._extract_m3u8_formats_and_subtitles( | |
329 | video_url, video_id, m3u8_id='vtt', fatal=False) | |
330 | continue | |
331 | elif media_format == 'm3u8' and tbr is not None: | |
332 | a_format.update({ | |
333 | 'format_id': join_nonempty('hls', tbr), | |
334 | 'ext': 'mp4', | |
335 | }) | |
336 | elif media_format == 'm3u8-variant' or ext == 'm3u8': | |
337 | # For some videos the initial m3u8 URL returns JSON instead | |
338 | manifest_json = self._download_json( | |
339 | video_url, video_id, note='Downloading manifest JSON', fatal=False) | |
340 | if manifest_json: | |
341 | video_url = manifest_json.get('master_m3u8') | |
342 | if not video_url: | |
343 | continue | |
344 | hls_fmts, hls_subs = self._extract_m3u8_formats_and_subtitles( | |
345 | video_url, video_id, ext='mp4', m3u8_id='hls', fatal=False) | |
346 | formats.extend(hls_fmts) | |
347 | continue | |
348 | elif ext == 'mp3' or media_format == 'mp3': | |
349 | a_format['vcodec'] = 'none' | |
350 | else: | |
351 | a_format.update({ | |
352 | 'width': int_or_none(published_url.get('width')), | |
353 | 'height': int_or_none(published_url.get('height')), | |
354 | }) | |
355 | formats.append(a_format) | |
356 | ||
357 | subtitles = {} | |
358 | for caption in video_data.get('captions', []): | |
359 | a_caption = { | |
360 | 'url': caption['url'], | |
361 | 'ext': 'tt' if caption.get('format') == 'SMPTE-TT' else None, | |
362 | } | |
363 | subtitles.setdefault(caption['language'], []).append(a_caption) | |
364 | subtitles = self._merge_subtitles(subtitles, hls_subs, vtt_subs) | |
365 | ||
366 | return { | |
367 | 'id': video_id, | |
368 | 'formats': formats, | |
369 | 'title': video_data.get('def_title'), | |
370 | 'description': video_data.get('def_description'), | |
371 | 'tags': video_data.get('def_tags', '').split(','), | |
372 | 'categories': video_data.get('categories'), | |
373 | 'thumbnail': video_data.get('src_image_url') or video_data.get('thumbnail'), | |
374 | 'timestamp': int_or_none(video_data.get( | |
375 | 'ts_published') or video_data.get('ts_added')), | |
376 | 'uploader': video_data.get('mcp_id'), | |
377 | 'duration': int_or_none(video_data.get('duration')), | |
378 | 'subtitles': subtitles, | |
379 | } | |
380 | ||
381 | @classmethod | |
382 | def _extract_from_webpage(cls, url, webpage): | |
383 | for mobj in re.finditer(cls._ANVP_RE, webpage): | |
384 | anvplayer_data = unescapeHTML(json.loads(mobj.group('anvp'))) or {} | |
385 | video_id, access_key = anvplayer_data.get('video'), anvplayer_data.get('accessKey') | |
386 | if not access_key: | |
387 | access_key = cls._MCP_TO_ACCESS_KEY_TABLE.get((anvplayer_data.get('mcp') or '').lower()) | |
388 | if not (video_id or '').isdigit() or not access_key: | |
389 | continue | |
390 | url = f'anvato:{access_key}:{video_id}' | |
391 | if anvplayer_data.get('token'): | |
392 | url = smuggle_url(url, {'token': anvplayer_data['token']}) | |
393 | yield cls.url_result(url, AnvatoIE, video_id) | |
394 | ||
395 | def _real_extract(self, url): | |
396 | url, smuggled_data = unsmuggle_url(url, {}) | |
397 | self._initialize_geo_bypass({ | |
398 | 'countries': smuggled_data.get('geo_countries'), | |
399 | }) | |
400 | ||
401 | access_key, video_id = self._match_valid_url(url).group('access_key_or_mcp', 'id') | |
402 | if access_key not in self._ANVACK_TABLE: | |
403 | access_key = self._MCP_TO_ACCESS_KEY_TABLE.get(access_key) or access_key | |
404 | return self._get_anvato_videos(access_key, video_id, smuggled_data.get('token')) |