pub struct Youtube { /* private fields */ }Expand description
YouTube TranscriptSource.
Holds a single reqwest::Client reused across the watch-page,
InnerTube, and timedtext calls. Cheap to construct; in steady state
it is fine to keep one instance per process.
On first use, a visitorData token is scraped from the watch page
and cached in tokio::sync::OnceCell. Concurrent first-callers
serialise on a single fetch rather than double-fetching, and every
subsequent InnerTube /player POST forwards the cached token.
Implementations§
Source§impl Youtube
impl Youtube
Sourcepub fn new() -> Result<Self>
pub fn new() -> Result<Self>
Construct a YouTube source with default HTTP settings (30 s timeout, ANDROID_VR User-Agent) targeting the public YouTube origin.
Sourcepub fn with_base_url(base_url: impl Into<String>) -> Result<Self>
pub fn with_base_url(base_url: impl Into<String>) -> Result<Self>
Construct a YouTube source pointed at an alternate origin. Used by
tests to inject a wiremock::MockServer::uri(). The HTTP client
retains the production timeout and User-Agent so request shape
matches the real client.
Trait Implementations§
Source§impl TranscriptSource for Youtube
impl TranscriptSource for Youtube
Source§fn name(&self) -> &'static str
fn name(&self) -> &'static str
"youtube"). Used
in error messages, the Transcript::source field, and as the
CLI subcommand name.Source§fn matches(url: &str) -> bool
fn matches(url: &str) -> bool
url as one of its locators. Used by
future auto-detection (omni-dev transcript fetch <url>). Read moreSource§fn fetch<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
locator: &'life1 str,
opts: &'life2 FetchOpts,
) -> Pin<Box<dyn Future<Output = Result<Transcript>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn fetch<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
locator: &'life1 str,
opts: &'life2 FetchOpts,
) -> Pin<Box<dyn Future<Output = Result<Transcript>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
locator to a transcript matching opts.