Skip to content

Commit

Permalink
switch to select_proxy with yt api hostname
Browse files Browse the repository at this point in the history
  • Loading branch information
grqx committed Sep 19, 2024
1 parent d97049e commit 231045e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 6 additions & 1 deletion plugin/yt_dlp_plugins/extractor/getpot_bgutil_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,19 @@ def _validate_get_pot(self, client: str, ydl: YoutubeDL, visitor_data=None, data

def _get_pot(self, client: str, ydl: YoutubeDL, visitor_data=None, data_sync_id=None, player_url=None, **kwargs) -> str:
self._logger.info('Generating POT via HTTP server')
if (proxy := select_proxy('https://jnn-pa.googleapis.com', self.proxies)
!= select_proxy('https://youtube.com', self.proxies)):
self._logger.warning(
'Proxies for https://youtube.com and https://jnn-pa.googleapis.com are different. '
'This is likely to cause subsequent errors.')

try:
response = ydl.urlopen(Request(
f'{self.base_url}/get_pot', data=json.dumps({
'client': client,
'visitor_data': visitor_data,
'data_sync_id': data_sync_id,
'proxy': select_proxy('http://youtube.com', self.proxies),
'proxy': proxy,
}).encode(), headers={'Content-Type': 'application/json'},
extensions={'timeout': 12.5}, proxies={'all': None}))
except Exception as e:
Expand Down
6 changes: 5 additions & 1 deletion plugin/yt_dlp_plugins/extractor/getpot_bgutil_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ def _get_pot(self, client: str, ydl: YoutubeDL, visitor_data=None, data_sync_id=
self._logger.info(
f'Generating POT via script: {self.script_path}')
command_args = ['node', self.script_path]
if proxy := select_proxy('http://youtube.com', self.proxies):
if proxy := select_proxy('https://jnn-pa.googleapis.com', self.proxies):
if proxy != select_proxy('https://youtube.com', self.proxies):
self._logger.warning(
'Proxies for https://youtube.com and https://jnn-pa.googleapis.com are different. '
'This is likely to cause subsequent errors.')
command_args.extend(['-p', proxy])
if data_sync_id:
command_args.extend(['-d', data_sync_id])
Expand Down

0 comments on commit 231045e

Please sign in to comment.