youtube

package
v0.4.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 6, 2026 License: MPL-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCaptionsNotFound = errors.New("captions not found for the specified language")
View Source
var ErrChannelNotFound = errors.New("channel not found")
View Source
var ErrVideoNotFound = errors.New("video not found")

Functions

This section is empty.

Types

type BaseChannel

type BaseChannel struct {
	ID string `js:"id"`
	// The channel's name
	Name string `js:"name"`
	// The channel's handle start with @
	Handle string `js:"handle"`
	// The channel's description
	Description string `js:"description"`
	// Thumbnails of this Channel
	Thumbnails shared.Thumbnails `js:"thumbnails"`
	// How many subscribers does this channel have.
	//
	// This is not the exact amount, but a literal string like `"1.95M subscribers"`
	SubscriberCount string `js:"subscriberCount"`
	// Continuable of videos
	Videos ChannelVideos
	// Continuable of shorts
	Shorts ChannelShorts
	// Continuable of live
	Live ChannelLive
	// Continuable of playlists
	Playlists ChannelPlaylists
	// Continuable of posts
	Posts ChannelPosts
	// The URL of the channel page
	URL string `js:"url"`
}

func (*BaseChannel) FromObject

func (x *BaseChannel) FromObject(vm *sobek.Runtime, obj *sobek.Object) error

type BaseVideo

type BaseVideo struct {
	ID string `js:"id"`
	// The title of this video
	Title string `js:"title"`
	// Thumbnails of the video with different sizes
	Thumbnails shared.Thumbnails `js:"thumbnails"`
	// The description of this video
	Description string `js:"description"`
	// The channel that uploaded this video
	Channel Option[BaseChannel]
	// The collaborators of this video
	Channels Option[[]BaseChannel]
	// The date this video is uploaded at
	UploadDate string `js:"uploadDate"`
	// How many views does this video have, None if the view count is hidden
	ViewCount Option[int64]
	// How many likes does this video have, None if the like count is hidden
	LikeCount Option[int64]
	// Whether this video is a live content or not
	IsLiveContent bool `js:"isLiveContent"`
	// The tags of this video
	Tags []string `js:"tags"`
	// Continuable of videos / playlists related to this video
	Related Continuable[VideoRelated] `js:"related"`
	// Captions helper class of this video (if caption exists in this video)
	Captions VideoCaptions
}

func (*BaseVideo) FromObject

func (x *BaseVideo) FromObject(vm *sobek.Runtime, obj *sobek.Object) error

type Caption

type Caption struct {
	// caption content
	Text string `js:"text"`
	// caption start time in milliseconds
	Start int64 `js:"start"`
	// caption duration in milliseconds
	Duration int64 `js:"duration"`
	// transcript end time in milliseconds
	End int64 `js:"end"`
}

type CaptionLanguage

type CaptionLanguage struct {
	// Caption language name
	Name string `js:"name"`
	// Caption language code
	Code string `js:"code"`
	// Whether this language is translatable
	IsTranslatable bool `js:"isTranslatable"`
	// Caption language url
	URL string `js:"url"`
}

type Channel

type Channel struct {
	BaseChannel
	// How many videos does this channel have
	VideoCount   string `js:"videoCount"`
	Banner       shared.Thumbnails
	MobileBanner shared.Thumbnails
	TvBanner     shared.Thumbnails
	Shelves      []shared.Shelf
}

func (*Channel) FromObject

func (x *Channel) FromObject(vm *sobek.Runtime, obj *sobek.Object) error

type ChannelLive

type ChannelLive = Continuable[VideoCompact]

type ChannelPlaylists

type ChannelPlaylists = Continuable[PlaylistCompact]

type ChannelPosts

type ChannelPosts = Continuable[Post]

type ChannelShorts

type ChannelShorts = Continuable[VideoCompact]

type ChannelVideos

type ChannelVideos = Continuable[VideoCompact]

type Chapter

type Chapter struct {
	Title      string `js:"title"`
	Start      int64  `js:"start"`
	Thumbnails shared.Thumbnails
}

func (*Chapter) FromObject

func (x *Chapter) FromObject(vm *sobek.Runtime, obj *sobek.Object) error

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(options *shared.ClientOptions) (Client, error)

func (Client) GetChannel

func (c Client) GetChannel(id string) (*Channel, error)

func (Client) GetVideo

func (c Client) GetVideo(id string) (VideoResult, error)

func (Client) OAuth added in v0.3.0

func (c Client) OAuth() (shared.OAuthProps, error)

type Comment

type Comment struct {
	ID string `js:"id"`
	// The video this comment belongs to
	Video Video
	// The comment's author
	Author BaseChannel
	// The content of this comment
	Content string `js:"content"`
	// The publish date of the comment
	PublishDate string `js:"publishDate"`
	// How many likes does this comment have
	LikeCount int64 `js:"likeCount"`
	// Whether the comment is posted by the video uploader / owner
	IsAuthorChannelOwner bool `js:"isAuthorChannelOwner"`
	// Whether the comment is pinned
	IsPinned bool `js:"isPinned"`
	// Reply count of this comment
	ReplyCount int64 `js:"replyCount"`
	// Continuable of replies in this comment
	Replies CommentReplies
	// URL to the video with this comment being highlighted (appears on top of the comment section)
	URL string `js:"url"`
}

func (*Comment) FromObject

func (x *Comment) FromObject(vm *sobek.Runtime, obj *sobek.Object) error

type CommentReplies

type CommentReplies = Continuable[Reply]

type Continuable

type Continuable[T any] struct {
	// contains filtered or unexported fields
}

func (*Continuable[T]) FromObject

func (x *Continuable[T]) FromObject(vm *sobek.Runtime, obj *sobek.Object) error

func (*Continuable[T]) Items

func (x *Continuable[T]) Items() ([]T, error)

func (*Continuable[T]) Next

func (x *Continuable[T]) Next(count int64) ([]T, error)

type LiveVideo

type LiveVideo struct{}

type MusicMetadata added in v0.4.0

type MusicMetadata struct {
	ImageUrl string `js:"imageUrl"`
	Title    string `js:"title"`
	Artist   string `js:"artist"`
	Album    Option[string]
}

func (*MusicMetadata) FromObject added in v0.4.0

func (x *MusicMetadata) FromObject(vm *sobek.Runtime, obj *sobek.Object) error

type PlaylistCompact

type PlaylistCompact struct {
	ID string `js:"id"`
	// The playlist's title
	Title string `js:"title"`
	// Thumbnails of the playlist with different sizes
	Thumbnails shared.Thumbnails
	// The channel that made this playlist
	Channel BaseChannel `js:"channel"`
	// How many videos in this playlist
	VideoCount int64 `js:"videoCount"`
}

func (*PlaylistCompact) FromObject

func (x *PlaylistCompact) FromObject(vm *sobek.Runtime, obj *sobek.Object) error

type Post

type Post struct {
	ID string `js:"id"`
	// The channel who posted this post
	Channel BaseChannel
	// The content of this post
	Content string `js:"content"`
	// Timestamp
	Timestamp string `js:"timestamp"`
	// Vote count like '1.2K likes'
	VoteCount string `js:"voteCount"`
}

func (*Post) FromObject

func (x *Post) FromObject(vm *sobek.Runtime, obj *sobek.Object) error

type Reply

type Reply struct {
	ID string `js:"id"`
	// The comment this reply belongs to
	Comment Comment
	// The video this reply belongs to
	Video Video `js:"video"`
	// The comment's author
	Author BaseChannel
	// The content of this comment
	Content string `js:"content"`
	// The publish date of the comment
	PublishDate string `js:"publishDate"`
	// How many likes does this comment have
	LikeCount int64 `js:"likeCount"`
	// Whether the comment is posted by the video uploader / owner
	IsAuthorChannelOwner bool `js:"isAuthorChannelOwner"`
}

func (*Reply) FromObject

func (x *Reply) FromObject(vm *sobek.Runtime, obj *sobek.Object) error

type Video

type Video struct {
	BaseVideo
	// The duration of this video in second
	Duration int64 `js:"duration"`
	// Chapters on this video if exists
	Chapters []Chapter
	// Continuable of videos inside a Video
	Comments VideoComments
	// Music metadata (if exists)
	Music Option[MusicMetadata]
}

func (*Video) FromObject

func (x *Video) FromObject(vm *sobek.Runtime, obj *sobek.Object) error

type VideoCaptions

type VideoCaptions struct {

	// List of available languages for this video
	Languages []CaptionLanguage `js:"languages"`
	// contains filtered or unexported fields
}

func (*VideoCaptions) FromObject

func (x *VideoCaptions) FromObject(vm *sobek.Runtime, obj *sobek.Object) error

func (*VideoCaptions) Get

func (x *VideoCaptions) Get(languageCode string, translationLanguageCode string) ([]Caption, error)

Get captions of a specific language or a translation of a specific language

func (*VideoCaptions) IsZero

func (x *VideoCaptions) IsZero() bool

type VideoComments

type VideoComments = Continuable[Comment]

type VideoCompact

type VideoCompact struct {
	ID string `js:"id"`
	// The title of the video
	Title string `js:"title"`
	// Thumbnails of the video with different sizes
	Thumbnails shared.Thumbnails
	// Description of the video (not a full description, rather a preview / snippet)
	Description string `js:"description"`
	// The duration of this video in second, None if the video is live
	Duration Option[int64]
	// Whether this video is a live now or not
	IsLive bool `js:"isLive"`
	// Whether this video is a shorts or not
	IsShort bool `js:"isShort"`
	// The channel who uploads this video
	Channel BaseChannel
	// The date this video is uploaded at
	UploadDate string `js:"uploadDate"`
	// How many views does this video have, None if the view count is hidden
	ViewCount Option[int64]
	// Whether this video is private / deleted or not, only useful in playlist's videos
	IsPrivateOrDeleted bool `js:"isPrivateOrDeleted"`
}

func (*VideoCompact) FromObject

func (x *VideoCompact) FromObject(vm *sobek.Runtime, obj *sobek.Object) error

type VideoRelated

type VideoRelated struct {
	VideoCompact    *VideoCompact
	PlaylistCompact *PlaylistCompact
}

func (*VideoRelated) FromValue

func (x *VideoRelated) FromValue(vm *sobek.Runtime, val sobek.Value) error

type VideoResult

type VideoResult struct {
	Video     *Video
	LiveVideo *LiveVideo
}

func (*VideoResult) FromValue

func (x *VideoResult) FromValue(vm *sobek.Runtime, val sobek.Value) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL