vivekchakraverty commited on
Commit
597c768
·
verified ·
1 Parent(s): 436c66c

Screenshots: 2-phase (HTTPS-proxy resolve + plain media-proxy chunked download + local ffmpeg)

Browse files
Files changed (1) hide show
  1. app.py +12 -1
app.py CHANGED
@@ -109,6 +109,14 @@ def _resolve_proxy() -> str | None:
109
  return proxy or None
110
 
111
 
 
 
 
 
 
 
 
 
112
  def _resolve_api_key(ui_key: str | None) -> str | None:
113
  key = (ui_key or "").strip() or os.environ.get("YOUTUBE_API_KEY", "").strip()
114
  return key or None
@@ -122,6 +130,8 @@ def check_access():
122
  proxies = {"http": proxy, "https": proxy} if proxy else None
123
  lines = [
124
  f"- **Proxy** (`YT_PROXY`): {'set ✅' if proxy else 'not set ⚪'}",
 
 
125
  f"- **Cookies** (`YT_COOKIES`): {'set ✅' if os.environ.get('YT_COOKIES') else 'not set ⚪'}",
126
  f"- **Data API key** (`YOUTUBE_API_KEY`): {'set ✅' if os.environ.get('YOUTUBE_API_KEY') else 'not set ⚪'}",
127
  ]
@@ -285,7 +295,8 @@ def run_pipeline(topic, hf_token, yt_api_key, llm_model, vlm_model,
285
  yield status(f"🎞️ Capturing {len(times)} screenshots at weighted timestamps…"), ranking, gr.update(value=transcript), gr.update()
286
  try:
287
  selected = frames_mod.capture_shots(
288
- times, best["video_id"], frames_dir, cookiefile, proxy, progress)
 
289
  except Exception as exc:
290
  yield (status(f"⚠️ Couldn't fetch screenshots — text-only tutorial. "
291
  f"`{type(exc).__name__}: {str(exc)[:400]}`"),
 
109
  return proxy or None
110
 
111
 
112
+ def _resolve_media_proxy() -> str | None:
113
+ """Plain HTTP proxy for large media (googlevideo.com) downloads. The TLS YT_PROXY
114
+ can't sustain multi-MB transfers, so screenshots use this instead; falls back to
115
+ YT_PROXY when unset."""
116
+ mp = os.environ.get("YT_MEDIA_PROXY", "").strip()
117
+ return mp or None
118
+
119
+
120
  def _resolve_api_key(ui_key: str | None) -> str | None:
121
  key = (ui_key or "").strip() or os.environ.get("YOUTUBE_API_KEY", "").strip()
122
  return key or None
 
130
  proxies = {"http": proxy, "https": proxy} if proxy else None
131
  lines = [
132
  f"- **Proxy** (`YT_PROXY`): {'set ✅' if proxy else 'not set ⚪'}",
133
+ f"- **Media proxy** (`YT_MEDIA_PROXY`, screenshots): "
134
+ f"{'set ✅' if _resolve_media_proxy() else 'not set ⚪ (falls back to YT_PROXY)'}",
135
  f"- **Cookies** (`YT_COOKIES`): {'set ✅' if os.environ.get('YT_COOKIES') else 'not set ⚪'}",
136
  f"- **Data API key** (`YOUTUBE_API_KEY`): {'set ✅' if os.environ.get('YOUTUBE_API_KEY') else 'not set ⚪'}",
137
  ]
 
295
  yield status(f"🎞️ Capturing {len(times)} screenshots at weighted timestamps…"), ranking, gr.update(value=transcript), gr.update()
296
  try:
297
  selected = frames_mod.capture_shots(
298
+ times, best["video_id"], frames_dir, cookiefile, proxy,
299
+ _resolve_media_proxy(), progress)
300
  except Exception as exc:
301
  yield (status(f"⚠️ Couldn't fetch screenshots — text-only tutorial. "
302
  f"`{type(exc).__name__}: {str(exc)[:400]}`"),