yt-transcript-rs 0.1.8

A Rust library for fetching and working with YouTube video transcripts
Documentation
#[cfg(not(feature = "ci"))]
use reqwest::Client;
use std::sync::Once;

use crate::api::YouTubeTranscriptApi;

static INIT: Once = Once::new();

/// Setup function that runs once before all tests
pub fn setup() {
    INIT.call_once(|| {
        // Initialize any global settings here
    });
}

/// Create a test instance of the YouTubeTranscriptApi
///
/// When in GitHub Actions or other CI environments, this will use mock data
/// instead of making real API calls to YouTube
#[cfg(feature = "ci")]
pub fn create_api() -> YouTubeTranscriptApi {
    // When running in CI, use the mock client
    let client = super::mocks::create_mock_client();

    YouTubeTranscriptApi::new(None, None, Some(client)).unwrap()
}

#[cfg(not(feature = "ci"))]
pub fn create_api() -> YouTubeTranscriptApi {
    // For local development, use a real client
    let client = Client::builder()
        .user_agent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36")
        .build()
        .unwrap();

    YouTubeTranscriptApi::new(None, None, Some(client)).unwrap()
}

/// Video ID with transcripts available in multiple languages
pub const MULTILANG_VIDEO_ID: &str = "arj7oStGLkU"; // Ted talk with multiple languages

/// Video ID with only auto-generated transcripts
pub const AUTOGENERATED_VIDEO_ID: &str = "";

/// Video ID with manually created transcripts
pub const MANUAL_VIDEO_ID: &str = "";

/// Non-existing video ID
pub const NON_EXISTENT_VIDEO_ID: &str = "xxxxxxxxxxx";

/// Age-restricted video ID
pub const AGE_RESTRICTED_VIDEO_ID: &str = "";

/// Video ID with disabled transcripts
pub const DISABLED_TRANSCRIPTS_VIDEO_ID: &str = "";