Yt::YouTubeClient
Handles interactions with the YouTube Data API v3.
This class provides methods to list, upload, update, and delete videos using either API key or OAuth2 access token authentication.
Example with API Key
client = YouTubeClient.new(api_key: "your_api_key")
video = client.get_video("dQw4w9WgXcQ")
Example with OAuth2
client = YouTubeClient.new(access_token: "your_access_token")
video = client.upload_video("video.mp4", "My Video Title")
Constants
Constructors
Instance methods
Delete a video by ID
video_id - The YouTube video ID (11 characters) Raises AuthenticationError if no access token is provided Raises ValidationError if video_id is invalid Raises NetworkError on network failures
Get a video by ID with full metadata
video_id - The YouTube video ID (11 characters) Returns the Video object with complete metadata Raises ValidationError if video_id is invalid Raises NotFoundError if video is not found Raises NetworkError on network failures
List videos from the authenticated user's channel
limit - Maximum number of videos to return (1-50, default: 5) Returns an array of Video objects Raises NetworkError on network failures Raises AuthenticationError on authentication failures Raises RateLimitError when rate limit is exceeded Raises ParseError on malformed responses
Update a video's metadata
video_id - The YouTube video ID to update title - New video title (optional) description - New video description (optional) privacy_status - New privacy status: "public", "private", or "unlisted" (optional) tags - Array of tags (optional) category_id - YouTube category ID (optional) default_language - Default language code (optional) default_audio_language - Default audio language code (optional) preserve_existing - If true, fetches existing video metadata to merge unchanged fields (default: true) Returns the updated Video object Raises ValidationError on invalid input Raises AuthenticationError if no access token is provided Raises NetworkError on network failures