Fix search latency: bypass rate limiter for user-triggered searches

search_youtube now takes polite=False (default) for instant user
searches and polite=True for background discovery crawls.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-27 01:27:36 +02:00
parent 86e7648075
commit b6a47249d0
2 changed files with 4 additions and 3 deletions

View File

@@ -107,7 +107,7 @@ def _search_and_store(
for query in queries: for query in queries:
try: try:
results = ytdlp.search_youtube(query, max_results=40) results = ytdlp.search_youtube(query, max_results=40, polite=True)
except Exception: except Exception:
results = [] results = []
for video in results: for video in results:

View File

@@ -152,9 +152,10 @@ def _normalize_channel(info: dict) -> dict:
} }
def search_youtube(query: str, max_results: int = 40) -> list[dict]: def search_youtube(query: str, max_results: int = 40, polite: bool = False) -> list[dict]:
"""Search YouTube via yt-dlp. Uses --flat-playlist for fast results.""" """Search YouTube via yt-dlp. Uses --flat-playlist for fast results."""
stdout, _, code = _meta_run([ runner = _meta_run if polite else _run
stdout, _, code = runner([
"yt-dlp", "yt-dlp",
f"ytsearch{max_results}:{query}", f"ytsearch{max_results}:{query}",
"--dump-json", "--dump-json",