wait a bit more time and more info about progress

This commit is contained in:
Emilien Devos 2024-07-20 10:57:35 +02:00
parent 26bdbf71b5
commit 174651a5a6
2 changed files with 7 additions and 2 deletions

View File

@ -1,6 +1,6 @@
#!/bin/sh
echo "internally launching GUI (X11 environment)"
echo "[INFO] internally launching GUI (X11 environment)"
rm -f /tmp/.X0-lock
@ -16,7 +16,7 @@ x11vnc -display :0 -forever -usepw &>/dev/null &
# Add delay
sleep 5
echo "launching the python script"
echo "[INFO] launching the python script"
# Run python script on display 0
DISPLAY=:0 python index.py

View File

@ -6,11 +6,13 @@ import sys
async def main():
tab_url = 'https://www.google.com/search?q=me+at+the+zoo&tbm=vid&source=lnms&hl=en&lr=lang_us'
print("[INFO] launching browser.")
browser = await start(headless=False)
tab = browser.main_tab
page = await browser.get(tab_url)
accept_terms = await tab.find("Accept all")
await accept_terms.click()
print("[INFO] accepting cookies.")
page = await browser.get(tab_url)
await tab.wait(cdp.network.RequestWillBeSent)
iframe = await tab.select("iframe")
@ -19,12 +21,15 @@ async def main():
lambda x: str(x.target.target_id) == str(iframe.frame_id), browser.targets
)
)
print("[INFO] finding youtube iframe.")
iframe_tab.websocket_url = iframe_tab.websocket_url.replace("iframe", "page")
iframe_tab.add_handler(cdp.network.RequestWillBeSent, send_handler)
await iframe_tab.wait(cdp.network.RequestWillBeSent)
button_play = await tab.select("div[data-url]")
await button_play.click()
print("[INFO] click on first youtube video.")
await iframe_tab.wait(cdp.network.RequestWillBeSent)
time.sleep(5)
async def send_handler(event: cdp.network.RequestWillBeSent):
if "/youtubei/v1/player" in event.request.url: