feat(youtube): optional egress proxy for YouTube API calls
New youtube_api_proxy setting (env fallback + admin Config UI, env YOUTUBE_API_PROXY): when set, the YouTubeClient routes all its httpx traffic through that HTTP(S) proxy. Lets a dynamic-IP host send API calls through a fixed-IP host (e.g. the server over private tunnel) so an IP-restricted API key keeps working. Empty = direct.
This commit is contained in:
parent
6c4c33f956
commit
d047ed7e15
6 changed files with 13 additions and 1 deletions
|
|
@ -44,7 +44,10 @@ class YouTubeClient:
|
|||
def __init__(self, db, user: User):
|
||||
self.db = db
|
||||
self.user = user
|
||||
self._http = httpx.Client(timeout=30.0)
|
||||
# Optionally route all YouTube traffic through a fixed-IP egress proxy (e.g. the VPS
|
||||
# over WireGuard) so an IP-restricted API key keeps working from a dynamic-IP host.
|
||||
proxy = sysconfig.get_str(db, "youtube_api_proxy") or None
|
||||
self._http = httpx.Client(timeout=30.0, proxy=proxy)
|
||||
|
||||
def __enter__(self) -> "YouTubeClient":
|
||||
return self
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue