bundle.youtube.browser

Attributes

Classes

PotoTokenEntity

Entity holding the extracted poto token and visitor data.

PotoTokenBrowser

Extension of the Playwright-based Browser that implements poto token extraction.

Functions

build_embed_url(→ str)

run()

Module Contents

bundle.youtube.browser.log
bundle.youtube.browser.DEFAULT_EMBED_URL = 'https://www.youtube-nocookie.com/embed/ouEl3qTLc0M?autoplay=1&mute=1'
bundle.youtube.browser.REFERER_ORIGIN = 'https://bundle.local'
bundle.youtube.browser.REFERER_URL = 'https://bundle.local/youtube/token'
bundle.youtube.browser.build_embed_url(embed_url: str) str[source]
class bundle.youtube.browser.PotoTokenEntity(/, **data: Any)[source]

Bases: bundle.core.entity.Entity

Entity holding the extracted poto token and visitor data.

name: str = None
potoken: str = None
visitor_data: str = None
class bundle.youtube.browser.PotoTokenBrowser(/, **data: Any)[source]

Bases: bundle.core.browser.Browser

Extension of the Playwright-based Browser that implements poto token extraction.

token_info: PotoTokenEntity = None
extraction_event: asyncio.Event = None
async handle_request(request: playwright.async_api.Request) None[source]

Inspect outgoing requests and extract the poto token if the request matches the expected criteria.

async click_player(page: playwright.async_api.Page, timeout: float = 10000) None[source]

Wait for the video player element and click it to trigger the token request.

async wait_for_extraction(timeout: float = 30.0) None[source]

Wait until the extraction event is set, indicating that token extraction is complete.

async extract_token(url: str | None = None, timeout: float = 30.0) PotoTokenEntity[source]

Orchestrates the token extraction process.

Steps:
  1. Open a new page.

  2. Attach the request handler to capture outgoing requests.

  3. Navigate to the target URL.

  4. Click the video player element to trigger the token request.

  5. Wait for the token extraction to complete.

  6. Close the page and return the extracted token.

Parameters:
  • url – The YouTube embed URL for token extraction.

  • timeout – Maximum time (in seconds) to wait for the extraction process.

Returns:

A PotoTokenEntity with the extracted token data, or None if extraction times out.

async bundle.youtube.browser.run()