- links_url = player_config['linksurl']
- links_data = self._download_json(urljoin(
- self._BASE_URL, links_url), video_id)
+ links_url = player_config.get('linksurl') or options['videoUrl']
+ 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,
+ })