- links_data = self._download_json(urljoin(
- self._BASE_URL, links_url), video_id)
+ token = options['token']
+ self._K = ''.join([random.choice('0123456789abcdef') for _ in range(16)])
+ message = bytes_to_intlist(json.dumps({
+ 'k': self._K,
+ 'e': 60,
+ 't': token,
+ }))
+ padded_message = intlist_to_bytes(pkcs1pad(message, 128))
+ n, e = self._RSA_KEY
+ encrypted_message = long_to_bytes(pow(bytes_to_long(padded_message), e, n))
+ authorization = base64.b64encode(encrypted_message).decode()
+ links_data = self._download_json(
+ urljoin(self._BASE_URL, links_url), video_id, headers={
+ 'Authorization': 'Bearer ' + authorization,
+ })