Documentation
¶
Index ¶
- func DecipherSignature(sig string) (string, error)
- func GetBaseJS() (string, error)
- func GetDethrottleSignature(streamURL string) (string, error)
- func GetPlayerName() (string, error)
- func GetSignatureTimestamp() (int, error)
- func SetCacheDir(dir string)
- type BrowseQuery
- type Caption
- type Channel
- type ClientContext
- type ContentPlaybackContext
- type DecipherFunctionData
- type MusicParam
- type MusicSearchResults
- type Param
- type PlaybackContext
- type Playlist
- type QueryContext
- type SearchParam
- type SearchQuery
- type SearchResults
- type SimpleAlbumPlaylist
- type SimpleArtistChannel
- type SimpleChannel
- type SimplePlaylist
- type SimpleVideo
- type SimpleVideoSearchResult
- type StreamFormat
- type StreamingFormats
- type ThirdPartyEmbed
- type Thumbnail
- type Video
- type VideoQuery
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecipherSignature ¶
DecipherSignature parses a "signature cipher" from a video like `s=AAOA...&sp=sig&url=https://rr4---sn-5uaeznld.googlevideo.com/videoplayback...` and returns a deciphered URL and any errors encountered.
func GetDethrottleSignature ¶
GetDethrottleSignature parses a stream URL like `https://rr4---sn-5uaeznld.googlevideo.com/videoplayback?...&n=yYOTSOeAS-63NqMqba&...` and returns the dethrottled value for the `n` key of the URL like `_SM0t1LByqSOuQ` (from `yYOTSOeAS-63NqMqba`) and any errors encountered.
func GetPlayerName ¶
GetPlayerName gets the name of the current player version.
func GetSignatureTimestamp ¶
func SetCacheDir ¶
func SetCacheDir(dir string)
SetCacheDir sets the cache directory to the supplied value.
Types ¶
type BrowseQuery ¶
type BrowseQuery struct {
BrowseID string `json:"browseId"`
Context QueryContext `json:"context"`
Param Param `json:"params,omitempty"`
}
BrowseQuery is the data sent to the YouTube browse endpoint (https://www.youtube.com/youtubei/v1/browse) after being JSON-encoded.
type Channel ¶
type Channel struct {
SimpleChannel
Links map[string]string
Banner []Thumbnail
TVBanner []Thumbnail
MobileBanner []Thumbnail
TotalVideos int
Videos []SimpleVideo
IsFamilySafe bool
AvailableCountries []string
}
Channel is a representation of the more complete data for a channel retrieved from the channel page on YouTube.
func GetChannel ¶
GetChannel returns data for a channel ID as Channel struct with any errors encountered.
type ClientContext ¶
type ClientContext struct {
ClientName string `json:"clientName"`
ClientVersion string `json:"clientVersion"`
SDKVersion int `json:"androidSdkVersion,omitempty"`
Language string `json:"hl,omitempty"`
}
ClientContext is a struct for wrapping client information for video queries.
type ContentPlaybackContext ¶
type ContentPlaybackContext struct {
SignatureTimestamp int `json:"signatureTimestamp"`
}
type DecipherFunctionData ¶
type DecipherFunctionData struct {
DecipherFunction string `json:"function"`
DecipherObject string `json:"object"`
}
DecipherFunctionData is the data necessary for deciphering a "signature cipher" for a video and is the format for the data is cached.
type MusicParam ¶
type MusicParam Param
SearchParam and MusicParam specify search type for YouTube and YouTube Music, respectively.
const ( MusicParamSongs MusicParam = "EgWKAQIIAWoMEAMQBBAOEAoQCRAF" MusicParamVideos MusicParam = "EgWKAQIQAWoMEAMQBBAOEAoQCRAF" MusicParamAlbums MusicParam = "EgWKAQIYAWoMEAMQBBAOEAoQCRAF" MusicParamArtists MusicParam = "EgWKAQIgAWoMEAMQBBAOEAoQCRAF" MusicParamFeaturedPlaylists MusicParam = "EgeKAQQoADgBagwQAxAEEA4QChAJEAU=" MusicParamCommunityPlaylists MusicParam = "EgeKAQQoAEABagwQAxAEEA4QChAJEAU=" )
Music search parameters are used for specifying types for YouTube Music search.
type MusicSearchResults ¶
type MusicSearchResults struct {
Songs *[]SimpleVideo
Videos *[]SimpleVideo
Albums *[]SimpleAlbumPlaylist
Artists *[]SimpleArtistChannel
FeaturedPlaylists *[]SimplePlaylist
CommunityPlaylists *[]SimplePlaylist
}
MusicSearchResults is a representation of search results returned from YouTube Music search.
func GetMusicSearchResults ¶
func GetMusicSearchResults(query string, param MusicParam, lang string) (MusicSearchResults, error)
GetMusicSearchResults returns search results for a YouTube Music search with the supplied query, search types, and language.
type Param ¶
type Param string
Param is a representation of the parameters supplied for specifying search types.
type PlaybackContext ¶
type PlaybackContext struct {
ContentPlaybackContext ContentPlaybackContext `json:"contentPlaybackContext"`
}
type Playlist ¶
type Playlist struct {
SimplePlaylist
Views int
Description string
LastUpdateDate time.Time
Videos []SimpleVideo
}
Playlist is a representation of the more complete data for a playlist retrieved from the playlist page on YouTube.
func GetPlaylist ¶
GetPlaylist returns data for a playlist ID as Playlist struct with any errors encountered.
type QueryContext ¶
type QueryContext struct {
Client ClientContext `json:"client"`
}
QueryContext is a struct for wrapping the ClientContext struct for video queries.
type SearchParam ¶
type SearchParam Param
SearchParam and MusicParam specify search type for YouTube and YouTube Music, respectively.
const ( SearchParamVideo SearchParam = "EgIQAQ==" SearchParamChannel SearchParam = "EgIQAg==" SearchParamPlaylist SearchParam = "EgIQAw==" SearchParamMovie SearchParam = "EgIQBA==" )
Search parameters are used for specifying types for YouTube search.
type SearchQuery ¶
type SearchQuery struct {
Context QueryContext `json:"context"`
Query string `json:"query"`
Param Param `json:"params"`
}
SearchQuery is the data sent to the YouTube search endpoint (https://www.youtube.com/youtubei/v1/search) after being JSON-encoded.
type SearchResults ¶
type SearchResults struct {
Videos *[]SimpleVideoSearchResult
Playlists *[]SimplePlaylist
Channels *[]SimpleChannel
}
SearchResults is a representation of search results returned from YouTube search.
func GetSearchResults ¶
func GetSearchResults(query string, param SearchParam, lang string) (SearchResults, error)
GetSearchResults returns search results for a YouTube search with the supplied query, search types, and language.
type SimpleAlbumPlaylist ¶
type SimpleAlbumPlaylist struct {
ID string
Title string
IsExplicit bool
ReleaseYear int
AlbumType string
ArtistChannelID string
ArtistChannelName string
Thumbnails []Thumbnail
}
SimpleAlbumPlaylist is a representation of the data retrieved from search results for an album on YouTube Music.
type SimpleArtistChannel ¶
SimpleArtistChannel is a representation of the data retrieved from search results for an artist on YouTube Music.
type SimpleChannel ¶
type SimpleChannel struct {
ID string
Name string
Username string
Avatars []Thumbnail
ShortDescription string
Subscribers int
IsVerified bool
}
SimpleArtistChannel is a representation of data retrieved from search results for an artist on YouTube Music.
type SimplePlaylist ¶
type SimplePlaylist struct {
ID string
Title string
VideoNumber int
CreatorChannelID string
CreatorChannelName string
Thumbnails []Thumbnail
}
SimplePlaylist is a representation of the data retrieved from search results for a playlist on YouTube.
type SimpleVideo ¶
type SimpleVideo struct {
ID string
Title string
Duration time.Duration
ChannelID string
ChannelName string
Thumbnails []Thumbnail
}
SimpleVideo is a representation of the simplified data retrieved for videos on YouTube on channel pages and some search results.
func GetFrontPageVideos ¶
func GetFrontPageVideos() ([]SimpleVideo, error)
GetFrontPageVideos returns the list of videos that are on the YouTube front page (https://www.youtube.com) as a slice of SimpleVideo structs. These videos will be random videos since no user data is saved (no user recommendations).
func GetTrendingVideos ¶
func GetTrendingVideos() ([]SimpleVideo, error)
GetTrendingVideos returns the list of videos that are currently trending as a slice of SimpleVideo structs.
type SimpleVideoSearchResult ¶
type SimpleVideoSearchResult struct {
SimpleVideo
ShortDescription string
RelativePublishDate string
Views int
}
SimpleVideoSearchResult is a representation of the data retrieved from search results for a video on YouTube.
type StreamFormat ¶
StreamFormat is a representation of the data present for a stream format for a YouTube video.
type StreamingFormats ¶
type StreamingFormats struct {
StaticFormats []StreamFormat
AdaptiveFormats []StreamFormat
}
StreamingFormats is a representation of the data present for streaming formats for a YouTube video.
type ThirdPartyEmbed ¶
type ThirdPartyEmbed struct {
EmbedURL string `json:"embedUrl"`
}
ThirdPartyEmbed is a struct for wrapping the embed URL for video queries.
type Video ¶
type Video struct {
SimpleVideo
Views int
UploadDate time.Time
PublishDate time.Time
Description string
Tags []string
Category string
AvailableCountries []string
RatingsAllowed bool
IsCrawlable bool
IsLive bool
IsPrivate bool
IsRestricted bool
IsUnlisted bool
StreamingData StreamingFormats
CaptionData []Caption
}
Video is a representation of the more complete data for a video retrieved from the video page on YouTube.
type VideoQuery ¶
type VideoQuery struct {
VideoID string `json:"videoId"`
Context QueryContext `json:"context"`
ThirdParty ThirdPartyEmbed `json:"thirdParty,omitempty"`
PlaybackContext PlaybackContext `json:"playbackContext,omitempty"`
}
VideoQuery is the data sent to the YouTube player endpoint (https://www.youtube.com/youtubei/v1/player) after being JSON-encoded.