make the script waiting for more seconds for the antibot script to load
Some checks failed
Docker Multi-Architecture Build / build-docker (push) Failing after 0s

fixes #7
This commit is contained in:
Emilien Devos 2024-09-16 23:08:06 +02:00
parent 4bd95c76f2
commit b4b4cb78b5

View File

@ -11,6 +11,8 @@ async def main():
tab.add_handler(cdp.network.RequestWillBeSent, send_handler)
page = await browser.get('https://www.youtube.com/embed/jNQXAC9IVRw')
await tab.wait(cdp.network.RequestWillBeSent)
print("[INFO] waiting 10 seconds for the page to fully load.")
await tab.sleep(10)
button_play = await tab.select("#movie_player")
await button_play.click()
await tab.wait(cdp.network.RequestWillBeSent)
@ -21,8 +23,12 @@ async def send_handler(event: cdp.network.RequestWillBeSent):
if "/youtubei/v1/player" in event.request.url:
post_data = event.request.post_data
post_data_json = json.loads(post_data)
print("visitor_data: " + post_data_json["context"]["client"]["visitorData"])
print("po_token: " + post_data_json["serviceIntegrityDimensions"]["poToken"])
visitor_data = post_data_json["context"]["client"]["visitorData"]
po_token = post_data_json["serviceIntegrityDimensions"]["poToken"]
print("visitor_data: " + visitor_data)
print("po_token: " + po_token)
if len(po_token) < 160:
print("[WARNING] there is a high chance that the potoken generated won't work. please try again on another internet connection.")
sys.exit(0)
return