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.
Sourcepub async fn resolve_channel_id(&self, input: &str) -> Result<String>
pub async fn resolve_channel_id(&self, input: &str) -> Result<String>
Resolve a channel locator (@handle, /c/Name, channel URL, or a raw
UC… ID) to its canonical UC… channel ID. See
channel::resolve_channel_id.
Sourcepub async fn recent_channel_videos(
&self,
channel_id: &str,
) -> Result<Vec<VideoEntry>>
pub async fn recent_channel_videos( &self, channel_id: &str, ) -> Result<Vec<VideoEntry>>
Enumerate a channel’s recent uploads via its RSS feed (newest-first,
~15 most recent). See channel::fetch_recent_videos.
Sourcepub async fn all_channel_video_ids(
&self,
channel_id: &str,
) -> Result<Vec<String>>
pub async fn all_channel_video_ids( &self, channel_id: &str, ) -> Result<Vec<String>>
Enumerate a channel’s full upload history via the InnerTube /browse
endpoint (newest-first). Uses the WEB client; no visitorData bootstrap
is needed (browse is a public endpoint). See
channel::fetch_all_video_ids.
Sourcepub async fn fetch_video_metadata(
&self,
video_id: &str,
) -> Result<VideoMetadata>
pub async fn fetch_video_metadata( &self, video_id: &str, ) -> Result<VideoMetadata>
Fetch per-video metadata (title, channel, publish date, view/like
counts, …) via a single WEB-client /player call.
Independent of the transcript path: it uses the un-gated WEB client
(see innertube::fetch_player_response_web) and needs no
visitorData bootstrap, so already-synced videos can be backfilled
or refreshed without touching the bot-gated ANDROID_VR path.
fetched_at is stamped at fetch time (UTC, second precision).
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.