bundle.youtube.browser¶
Attributes¶
Classes¶
Entity holding the extracted poto token and visitor data. |
|
Extension of the Playwright-based Browser that implements poto token extraction. |
Functions¶
|
|
|
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'¶
- class bundle.youtube.browser.PotoTokenEntity(/, **data: Any)[source]¶
Bases:
bundle.core.entity.EntityEntity holding the extracted poto token and visitor data.
- class bundle.youtube.browser.PotoTokenBrowser(/, **data: Any)[source]¶
Bases:
bundle.core.browser.BrowserExtension 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:
Open a new page.
Attach the request handler to capture outgoing requests.
Navigate to the target URL.
Click the video player element to trigger the token request.
Wait for the token extraction to complete.
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()¶