youtube

package
v0.0.0-...-eb951b6 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2025 License: CC0-1.0 Imports: 39 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BroadcastTypeAll
	BroadcastTypeUpcoming
	BroadcastTypeActive
)
View Source
const (
	EventTypeCompleted = EventType("completed")
	EventTypeLive      = EventType("live")
	EventTypeUpcoming  = EventType("upcoming")
)
View Source
const (
	TemplateTagsUndefined       = youtube.TemplateTagsUndefined
	TemplateTagsIgnore          = youtube.TemplateTagsIgnore
	TemplateTagsUseAsPrimary    = youtube.TemplateTagsUseAsPrimary
	TemplateTagsUseAsAdditional = youtube.TemplateTagsUseAsAdditional
)
View Source
const ID = youtube.ID
View Source
const (
	LimitTagsLength = 500
)

Variables

This section is empty.

Functions

func CalculateTagsLength

func CalculateTagsLength(tags []string) int

func InitConfig

func InitConfig(cfg streamctl.Config)

func ParseTimestamp

func ParseTimestamp(s string) (time.Time, error)

func TruncateTags

func TruncateTags(tags []string) []string

Types

type BroadcastType

type BroadcastType int

func (BroadcastType) String

func (t BroadcastType) String() string

type ChatClient

type ChatClient interface {
	GetLiveChatMessages(ctx context.Context, chatID string, pageToken string, parts []string) (*youtube.LiveChatMessageListResponse, error)
}

type ChatListener

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

func NewChatListener

func NewChatListener(
	ctx context.Context,
	ytClient ChatClient,
	videoID string,
	liveChatID string,
) (*ChatListener, error)

func (*ChatListener) Close

func (h *ChatListener) Close(ctx context.Context) error

func (*ChatListener) GetVideoID

func (h *ChatListener) GetVideoID() string

func (*ChatListener) MessagesChan

func (h *ChatListener) MessagesChan() <-chan streamcontrol.Event

type ChatListenerOBSOLETE

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

TODO: delete this handler after explaining to YouTube the application and getting a quota for normal ChatListener.

func NewChatListenerOBSOLETE

func NewChatListenerOBSOLETE(
	ctx context.Context,
	videoID string,
	onClose func(context.Context, *chatListener),
) (*ChatListenerOBSOLETE, error)

func (*ChatListenerOBSOLETE) Close

func (h *ChatListenerOBSOLETE) Close(ctx context.Context) (_err error)

func (*ChatListenerOBSOLETE) GetVideoID

func (h *ChatListenerOBSOLETE) GetVideoID() string

func (*ChatListenerOBSOLETE) MessagesChan

func (h *ChatListenerOBSOLETE) MessagesChan() <-chan streamcontrol.Event

type ClientCalcPoints

type ClientCalcPoints struct {
	Client          client
	UsedPoints      atomic.Uint64
	CheckMutex      sync.Mutex
	PreviousCheckAt time.Time
}

see also: https://developers.google.com/youtube/v3/determine_quota_cost

func NewYouTubeClientCalcPoints

func NewYouTubeClientCalcPoints(client client) *ClientCalcPoints

func (*ClientCalcPoints) DeleteBroadcast

func (c *ClientCalcPoints) DeleteBroadcast(
	ctx context.Context,
	broadcastID string,
) (_err error)

func (*ClientCalcPoints) DeleteChatMessage

func (c *ClientCalcPoints) DeleteChatMessage(
	ctx context.Context,
	messageID string,
) (_err error)

func (*ClientCalcPoints) GetBroadcasts

func (c *ClientCalcPoints) GetBroadcasts(
	ctx context.Context,
	t BroadcastType,
	ids []string,
	parts []string,
	pageToken string,
) (_ret *youtube.LiveBroadcastListResponse, _err error)

func (*ClientCalcPoints) GetLiveChatMessages

func (c *ClientCalcPoints) GetLiveChatMessages(
	ctx context.Context,
	chatID string,
	pageToken string,
	parts []string,
) (_ret *youtube.LiveChatMessageListResponse, _err error)

func (*ClientCalcPoints) GetPlaylistItems

func (c *ClientCalcPoints) GetPlaylistItems(
	ctx context.Context,
	playlistID string,
	videoID string,
	parts []string,
) (_ret *youtube.PlaylistItemListResponse, _err error)

func (*ClientCalcPoints) GetPlaylists

func (c *ClientCalcPoints) GetPlaylists(
	ctx context.Context,
	playlistParts []string,
) (_ret *youtube.PlaylistListResponse, _err error)

func (*ClientCalcPoints) GetStreams

func (c *ClientCalcPoints) GetStreams(
	ctx context.Context,
	parts []string,
) (_ret *youtube.LiveStreamListResponse, _err error)

func (*ClientCalcPoints) GetVideos

func (c *ClientCalcPoints) GetVideos(
	ctx context.Context,
	broadcastIDs []string,
	parts []string,
) (_ret *youtube.VideoListResponse, _err error)

func (*ClientCalcPoints) InsertBroadcast

func (c *ClientCalcPoints) InsertBroadcast(
	ctx context.Context,
	broadcast *youtube.LiveBroadcast,
	parts []string,
) (_ret *youtube.LiveBroadcast, _err error)

func (*ClientCalcPoints) InsertCommentThread

func (c *ClientCalcPoints) InsertCommentThread(
	ctx context.Context,
	t *youtube.CommentThread,
	parts []string,
) (_err error)

func (*ClientCalcPoints) InsertCuepoint

func (c *ClientCalcPoints) InsertCuepoint(
	ctx context.Context,
	cuepoint *youtube.Cuepoint,
) (_err error)

func (*ClientCalcPoints) InsertPlaylistItem

func (c *ClientCalcPoints) InsertPlaylistItem(
	ctx context.Context,
	item *youtube.PlaylistItem,
	parts []string,
) (_err error)

func (*ClientCalcPoints) ListChatMessages

func (c *ClientCalcPoints) ListChatMessages(
	ctx context.Context,
	chatID string,
	parts []string,
) (_ret *youtube.LiveChatMessageListResponse, _err error)

func (*ClientCalcPoints) Ping

func (c *ClientCalcPoints) Ping(ctx context.Context) (_err error)

func (*ClientCalcPoints) Search

func (c *ClientCalcPoints) Search(
	ctx context.Context,
	chanID string,
	eventType EventType,
	parts []string,
) (_ret *youtube.SearchListResponse, _err error)

func (*ClientCalcPoints) SetThumbnail

func (c *ClientCalcPoints) SetThumbnail(
	ctx context.Context,
	broadcastID string,
	thumbnail io.Reader,
) (_err error)

func (*ClientCalcPoints) UpdateBroadcast

func (c *ClientCalcPoints) UpdateBroadcast(
	ctx context.Context,
	broadcast *youtube.LiveBroadcast,
	parts []string,
) (_err error)

func (*ClientCalcPoints) UpdateVideo

func (c *ClientCalcPoints) UpdateVideo(
	ctx context.Context,
	video *youtube.Video,
	parts []string,
) (_err error)

type Config

type Config = youtube.Config

func GetConfig

func GetConfig(
	ctx context.Context,
	cfg streamcontrol.Config,
) *Config

type ErrChatDisabled

type ErrChatDisabled struct {
	ChatID string
}

func (ErrChatDisabled) Error

func (e ErrChatDisabled) Error() string

type ErrChatEnded

type ErrChatEnded struct {
	ChatID string
}

func (ErrChatEnded) Error

func (e ErrChatEnded) Error() string

type ErrChatNotFound

type ErrChatNotFound struct {
	ChatID string
}

func (ErrChatNotFound) Error

func (e ErrChatNotFound) Error() string

type EventType

type EventType string

type FlagBroadcastTemplateIDs

type FlagBroadcastTemplateIDs []string

type LiveBroadcast

type LiveBroadcast = youtube.LiveBroadcast

type OAuthHandler

type OAuthHandler = youtube.OAuthHandler

type PlatformSpecificConfig

type PlatformSpecificConfig = youtube.PlatformSpecificConfig

type StreamProfile

type StreamProfile = youtube.StreamProfile

type StreamStatusCustomData

type StreamStatusCustomData = youtube.StreamStatusCustomData

type TemplateTags

type TemplateTags = youtube.TemplateTags

type YouTube

type YouTube struct {
	Config         Config
	YouTubeClient  *ClientCalcPoints
	CancelFunc     context.CancelFunc
	SaveConfigFunc func(Config) error
	// contains filtered or unexported fields
}

func New

func New(
	ctx context.Context,
	cfg Config,
	saveCfgFn func(Config) error,
) (*YouTube, error)

func (*YouTube) ApplyProfile

func (yt *YouTube) ApplyProfile(
	ctx context.Context,
	profile StreamProfile,
	customArgs ...any,
) error

func (*YouTube) BanUser

func (yt *YouTube) BanUser(
	ctx context.Context,
	userID streamcontrol.UserID,
	reason string,
	deadline time.Time,
) error

func (*YouTube) Close

func (yt *YouTube) Close() error

func (*YouTube) DeleteActiveBroadcasts

func (yt *YouTube) DeleteActiveBroadcasts(
	ctx context.Context,
) error

func (*YouTube) EndStream

func (yt *YouTube) EndStream(
	ctx context.Context,
) error

func (*YouTube) Flush

func (yt *YouTube) Flush(
	ctx context.Context,
) error

func (*YouTube) GetChatMessagesChan

func (yt *YouTube) GetChatMessagesChan(
	ctx context.Context,
) (<-chan streamcontrol.Event, error)

func (*YouTube) GetStreamStatus

func (yt *YouTube) GetStreamStatus(
	ctx context.Context,
) (_ret *streamcontrol.StreamStatus, _err error)

func (*YouTube) InsertAdsCuePoint

func (yt *YouTube) InsertAdsCuePoint(
	ctx context.Context,
	ts time.Time,
	duration time.Duration,
) error

func (*YouTube) IsCapable

func (yt *YouTube) IsCapable(
	ctx context.Context,
	cap streamcontrol.Capability,
) bool

func (*YouTube) IsChannelStreaming

func (yt *YouTube) IsChannelStreaming(
	ctx context.Context,
	chanID streamcontrol.UserID,
) (_ret bool, _err error)

func (*YouTube) IterateActiveBroadcasts

func (yt *YouTube) IterateActiveBroadcasts(
	ctx context.Context,
	callback func(broadcast *youtube.LiveBroadcast) error,
	parts ...string,
) error

func (*YouTube) IterateUpcomingBroadcasts

func (yt *YouTube) IterateUpcomingBroadcasts(
	ctx context.Context,
	callback func(broadcast *youtube.LiveBroadcast) error,
	parts ...string,
) error

func (*YouTube) ListBroadcasts

func (yt *YouTube) ListBroadcasts(
	ctx context.Context,
	limit uint,
	continueFunc func(*youtube.LiveBroadcastListResponse) bool,
) (_ret []*youtube.LiveBroadcast, _err error)

func (*YouTube) ListStreams

func (yt *YouTube) ListStreams(
	ctx context.Context,
) ([]*youtube.LiveStream, error)

func (*YouTube) RaidTo

func (yt *YouTube) RaidTo(
	ctx context.Context,
	chanID streamcontrol.UserID,
) error

func (*YouTube) RemoveChatMessage

func (yt *YouTube) RemoveChatMessage(
	ctx context.Context,
	messageID streamcontrol.EventID,
) (_err error)

func (*YouTube) SendChatMessage

func (yt *YouTube) SendChatMessage(
	ctx context.Context,
	message string,
) (_err error)

func (*YouTube) SetDescription

func (yt *YouTube) SetDescription(
	ctx context.Context,
	description string,
) error

func (*YouTube) SetTitle

func (yt *YouTube) SetTitle(
	ctx context.Context,
	title string,
) error

func (*YouTube) Shoutout

func (yt *YouTube) Shoutout(
	ctx context.Context,
	chanID streamcontrol.UserID,
) error

func (*YouTube) StartStream

func (yt *YouTube) StartStream(
	ctx context.Context,
	title string,
	description string,
	profile StreamProfile,
	customArgs ...any,
) (_err error)

Directories

Path Synopsis
cmd
chatlistener command