youtube

package
v0.0.0-...-2319eaa Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2022 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetBestThumbnail

func GetBestThumbnail(thumbnails SnippetThumbnails) string

func GetChannelID

func GetChannelID(url string) (string, error)

For a given youtube channel URL

func IsYoutubeChannel

func IsYoutubeChannel(url string) bool

Types

type ChannelBrandingSettings

type ChannelBrandingSettings struct {
	Image ChannelBrandingSettingsImage `json:"image"`
}

type ChannelBrandingSettingsImage

type ChannelBrandingSettingsImage struct {
	BannerExternalURL string `json:"bannerExternalUrl"`
}

type ChannelItem

type ChannelItem struct {
	Kind             string                  `json:"kind"`
	Etag             string                  `json:"etag"`
	ID               string                  `json:"id"`
	Snippet          ChannelItemSnippet      `json:"snippet"`
	BrandingSettings ChannelBrandingSettings `json:"brandingSettings"`
}

type ChannelItemSnippet

type ChannelItemSnippet struct {
	Title       string            `json:"title"`
	Description string            `json:"description"`
	PublishedAt time.Time         `json:"publishedAt"`
	Country     string            `json:"country"`
	Thumbnails  SnippetThumbnails `json:"thumbnails"`
}

type FetchResponse

type FetchResponse[T any] struct {
	Kind     string   `json:"kind"`
	Etag     string   `json:"etag"`
	PageInfo PageInfo `json:"pageInfo"`
	Items    []T      `json:"items"`
}

type PageInfo

type PageInfo struct {
	TotalResults   int `json:"totalResults"`
	ResultsPerPage int `json:"resultsPerPage"`
}

type SnippetThumbnail

type SnippetThumbnail struct {
	URL    string `json:"url"`
	Width  int    `json:"width"`
	Height int    `json:"height"`
}

type SnippetThumbnails

type SnippetThumbnails struct {
	Default  SnippetThumbnail  `json:"default"`
	Medium   *SnippetThumbnail `json:"medium"`
	High     *SnippetThumbnail `json:"high"`
	Standard *SnippetThumbnail `json:"standard"`
}

type VideoItem

type VideoItem struct {
	Kind    string       `json:"kind"`
	Etag    string       `json:"etag"`
	ID      VideoItemID  `json:"id"`
	Snippet VideoSnippet `json:"snippet"`
}

type VideoItemID

type VideoItemID struct {
	Kind    string `json:"kind"`
	VideoID string `json:"videoId"`
}

type VideoSnippet

type VideoSnippet struct {
	PublishedAt          time.Time         `json:"publishedAt"`
	ChannelID            string            `json:"channelId"`
	Title                string            `json:"title"`
	Description          string            `json:"description"`
	ChannelTitle         string            `json:"channelTitle"`
	LiveBroadcastContent string            `json:"liveBroadcastContent"`
	Thumbnails           SnippetThumbnails `json:"thumbnails"`
}

type YoutubeClient

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

func New

func New(apiKey string) *YoutubeClient

func (*YoutubeClient) FetchChannel

func (y *YoutubeClient) FetchChannel(channelID string) (FetchResponse[ChannelItem], error)

func (*YoutubeClient) FetchVideos

func (y *YoutubeClient) FetchVideos(channelID string) (FetchResponse[VideoItem], error)

Jump to

Keyboard shortcuts

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