mirror of
https://github.com/iv-org/youtube-trusted-session-generator.git
synced 2025-01-16 00:22:20 +01:00
28 lines
No EOL
937 B
Python
28 lines
No EOL
937 B
Python
import asyncio
|
|
from nodriver import start, cdp, loop
|
|
import time
|
|
import json
|
|
import sys
|
|
|
|
async def main():
|
|
browser = await start(headless=True)
|
|
tab = browser.main_tab
|
|
tab.add_handler(cdp.network.RequestWillBeSent, send_handler)
|
|
page = await browser.get('https://www.youtube.com/embed/jNQXAC9IVRw')
|
|
await tab.wait(cdp.network.RequestWillBeSent)
|
|
button_play = await tab.select("#movie_player")
|
|
await button_play.click()
|
|
time.sleep(5)
|
|
|
|
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"])
|
|
sys.exit(0)
|
|
return
|
|
|
|
if __name__ == '__main__':
|
|
|
|
loop().run_until_complete(main()) |