Malina Claude Opus 4.8 commited on
Commit
8a9ebda
·
1 Parent(s): d0ff022

fetch: add proxy support + cookie/proxy diagnostic logging

Browse files

YouTube's datacenter-IP bot wall needs cookies or a proxy. Log whether each is
wired (so the Space logs confirm the secret is picked up) and honor YT_DLP_PROXY.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

Files changed (1) hide show
  1. fetch.py +7 -0
fetch.py CHANGED
@@ -84,6 +84,13 @@ def fetch_video(url: str, token: str = ""):
84
  cookies = _cookiefile()
85
  if cookies:
86
  opts["cookiefile"] = cookies
 
 
 
 
 
 
 
87
 
88
  try:
89
  with yt_dlp.YoutubeDL(opts) as ydl:
 
84
  cookies = _cookiefile()
85
  if cookies:
86
  opts["cookiefile"] = cookies
87
+ # Optional residential/HTTP proxy — the other way past datacenter-IP bot walls.
88
+ proxy = os.getenv("YT_DLP_PROXY")
89
+ if proxy:
90
+ opts["proxy"] = proxy
91
+ # Diagnostic: surfaces in the Space logs so you can confirm the secret is wired.
92
+ print(f"[NINA] fetch: cookies={'yes' if cookies else 'NO'}, "
93
+ f"proxy={'yes' if proxy else 'no'} — {url[:80]}")
94
 
95
  try:
96
  with yt_dlp.YoutubeDL(opts) as ydl: