MCPcopy
hub / github.com/yt-dlp/yt-dlp / _download_json

Method _download_json

yt_dlp/extractor/udemy.py:142–161  ·  view source on GitHub ↗
(self, url_or_request, *args, **kwargs)

Source from the content-addressed store, hash-verified

140 return ret
141
142 def _download_json(self, url_or_request, *args, **kwargs):
143 headers = {
144 'X-Udemy-Snail-Case': 'true',
145 'X-Requested-With': 'XMLHttpRequest',
146 }
147 for cookie in self.cookiejar:
148 if cookie.name == 'client_id':
149 headers['X-Udemy-Client-Id'] = cookie.value
150 elif cookie.name == 'access_token':
151 headers['X-Udemy-Bearer-Token'] = cookie.value
152 headers['X-Udemy-Authorization'] = f'Bearer {cookie.value}'
153
154 if isinstance(url_or_request, Request):
155 url_or_request.headers.update(headers)
156 else:
157 url_or_request = Request(url_or_request, headers=headers)
158
159 response = super()._download_json(url_or_request, *args, **kwargs)
160 self._handle_error(response)
161 return response
162
163 def _perform_login(self, username, password):
164 login_popup = self._download_webpage(

Callers 15

_download_lectureMethod · 0.95
test_download_jsonMethod · 0.45
_real_extractMethod · 0.45
_real_extractMethod · 0.45
_call_apiMethod · 0.45
_real_extractMethod · 0.45
_real_extractMethod · 0.45
_real_extractMethod · 0.45
_real_extractMethod · 0.45
fetch_pageMethod · 0.45
_call_apiMethod · 0.45
_real_extractMethod · 0.45

Calls 3

_handle_errorMethod · 0.95
RequestClass · 0.85
updateMethod · 0.45

Tested by 3

test_download_jsonMethod · 0.36
_real_extractMethod · 0.36
_real_extractMethod · 0.36