Add YouTube provider

This commit is contained in:
hlohaus 2025-07-14 08:49:12 +02:00
parent 89a45f38b6
commit c718011cb8
5 changed files with 138 additions and 1 deletions

View file

@ -131,7 +131,15 @@ class Video(AsyncGeneratorProvider, ProviderModelMixin):
for _, urls in RequestConfig.urls.items():
if event.request.url in urls:
return
debug.log(f"Adding URL: {event.request.url}")
RequestConfig.urls[prompt].append(event.request.url)
for idx in range(300):
button = await page.find("User menu")
if button:
break
if idx == 299:
stop_browser()
raise RuntimeError("Failed to wait for user menu.")
if model == "search" and page is not None:
await page.send(nodriver.cdp.network.enable())
page.add_handler(nodriver.cdp.network.RequestWillBeSent, on_request)