OpenRoadCode
Public API reference for OpenRoadCode
Loading...
Searching...
No Matches
video.youtube_player.YouTubePlayer Class Reference

Own a dedicated browser lifecycle for YouTube presentation. More...

Public Member Functions

None __init__ (self, *, str|Path profile_path=DEFAULT_YOUTUBE_PROFILE_PATH, tuple[str,...] browser_candidates=("google-chrome", "google-chrome-stable", "chromium", "chromium-browser",), bool software_rendering=False, bool dark_mode=False)
 Configure a YouTube player.
bool play (self, str target, *, str display, tuple[int, int]|None window_position=None, tuple[int, int]|None window_size=None)
 Open a YouTube URL or search query.
None stop (self)
 Stop the browser process owned by this player.
bool is_active (self)
 Return whether the owned YouTube browser process is running.

Static Public Member Functions

str resolve_target (str target)
 Convert search text to a YouTube URL or validate a direct URL.

Detailed Description

Own a dedicated browser lifecycle for YouTube presentation.

Constructor & Destructor Documentation

◆ __init__()

None video.youtube_player.YouTubePlayer.__init__ ( self,
* ,
str | Path profile_path = DEFAULT_YOUTUBE_PROFILE_PATH,
tuple[str, ...] browser_candidates = (             "google-chrome",             "google-chrome-stable",             "chromium",             "chromium-browser",         ),
bool software_rendering = False,
bool dark_mode = False )

Configure a YouTube player.

Parameters
profile_pathPersistent browser profile used for YouTube sessions.
browser_candidatesBrowser executables in preference order.
software_renderingDisable GPU paths for compatibility when true.
dark_modeRequest browser dark presentation when true.

Member Function Documentation

◆ play()

bool video.youtube_player.YouTubePlayer.play ( self,
str target,
* ,
str display,
tuple[int, int] | None window_position = None,
tuple[int, int] | None window_size = None )

Open a YouTube URL or search query.

Parameters
targetYouTube HTTPS URL or search text.
displayX11 display used by the browser.
window_positionOptional initial X/Y position.
window_sizeOptional initial width/height.
Returns
True after the browser launch request succeeds.

◆ resolve_target()

str video.youtube_player.YouTubePlayer.resolve_target ( str target)
static

Convert search text to a YouTube URL or validate a direct URL.

Parameters
targetSearch text or direct YouTube URL.
Returns
Valid YouTube HTTPS URL.
Exceptions
ValueErrorWhen a direct URL is non-HTTPS or outside YouTube.

The documentation for this class was generated from the following file:
  • controllers/video/youtube_player.py