class

Yt::Models::Video

Inherits JSON::Serializable < Reference < Object

Represents a YouTube video resource with essential metadata.

This class provides a strongly-typed representation of YouTube video data returned from the YouTube Data API v3.

Example

video = Video.new(
  id: "dQw4w9WgXcQ",
  title: "Never Gonna Give You Up",
  privacy_status: "public"
)
video.valid_id? # => true

Constructors

new(id : String, title : String | Nil = nil, privacy_status : String | Nil = nil, published_at : Time | Nil = nil, description : String | Nil = nil, tags : Array(String) | Nil = nil, category_id : String | Nil = nil, duration : String | Nil = nil, default_language : String | Nil = nil, default_audio_language : String | Nil = nil, channel_title : String | Nil = nil)

Create a new Video instance

Source
new(*, __pull_for_json_serializable pull : JSON::PullParser)
Source

Instance methods

category_id

Category ID (e.g. "22" for People & Blogs)

Source
category_id=(category_id : String | Nil)

Category ID (e.g. "22" for People & Blogs)

Source
channel_title

Channel title / author

Source
channel_title=(channel_title : String | Nil)

Channel title / author

Source
default_audio_language

Default audio language code

Source
default_audio_language=(default_audio_language : String | Nil)

Default audio language code

Source
default_language

Default language code (e.g. "es", "en")

Source
default_language=(default_language : String | Nil)

Default language code (e.g. "es", "en")

Source
description

Video description

Source
description=(description : String | Nil)

Video description

Source
display_title

Get the title, defaulting to "Untitled" if nil

Source
duration

Video duration in ISO 8601 format (e.g. PT1H23M45S)

Source
duration=(duration : String | Nil)

Video duration in ISO 8601 format (e.g. PT1H23M45S)

Source
formatted_publish_date

Get formatted publish date

Source
id

Unique YouTube video identifier (11 characters)

Source
id=(id : String)

Unique YouTube video identifier (11 characters)

Source
privacy_status

Privacy status (public, private, or unlisted)

Source
privacy_status=(privacy_status : String | Nil)

Privacy status (public, private, or unlisted)

Source
private?

Check if video is private

Source
public?

Check if video is publicly accessible

Source
published_at

When the video was published

Source
published_at=(published_at : Time | Nil)

When the video was published

Source
tags

Video tags / keywords

Source
tags=(tags : Array(String) | Nil)

Video tags / keywords

Source
title

Video title

Source
title=(title : String | Nil)

Video title

Source
to_metadata_json

Formatted metadata representation for CLI or editing

Source
unlisted?

Check if video is unlisted

Source
valid_id?

Check if the video ID is valid (11 alphanumeric characters)

Source