Skip to content

Commit

Permalink
reverting back to youtube embed page
Browse files Browse the repository at this point in the history
  • Loading branch information
unixfox committed Jul 20, 2024
1 parent 8e3cd89 commit c7ea8d6
Showing 1 changed file with 5 additions and 20 deletions.
25 changes: 5 additions & 20 deletions index.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,15 @@
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)
print("[INFO] launching browser.")
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)
tab.add_handler(cdp.network.RequestWillBeSent, send_handler)
page = await browser.get('https://www.youtube.com/embed/jNQXAC9IVRw')
await tab.wait(cdp.network.RequestWillBeSent)
iframe = await tab.select("iframe")
iframe_tab: uc.Tab = next(
filter(
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]")
button_play = await tab.select("#movie_player")
await button_play.click()
print("[INFO] click on first youtube video.")
await iframe_tab.wait(cdp.network.RequestWillBeSent)
await tab.wait(cdp.network.RequestWillBeSent)
print("[INFO] waiting additional 30 seconds for slower connections.")
await tab.sleep(30)

Expand Down

0 comments on commit c7ea8d6

Please sign in to comment.