Documentation ¶
Index ¶
- Constants
- func GetStream(client *http.Client, channelName, accessToken, streamQuality string) (*m3u8.Variant, error)
- func InitEnv(redisURL string)
- func SaveUsersCurrentStream(user *User, stream *Stream)
- type ChannelAccessToken
- type Follow
- type Follows
- type Pagination
- type PlaybackCommand
- type Stream
- type StreamsResponse
- type User
- type UserResponse
Constants ¶
const ( GetCurrentTwitchUserURL = "https://api.twitch.tv/helix/users" GetUserFollowsURLFormat = "https://api.twitch.tv/helix/users/follows?from_id=%s" GetLiveStreamsURLFormat = "https://api.twitch.tv/helix/streams?type=live&user_id=%s" GetChannelAccessTokenFormat = "https://api.twitch.tv/api/channels/%s/access_token?client_id=%s" GetStreamsURLFormat = "" /* 135-byte string literal not displayed */ )
The constant definitions for the URLs to be used to interact with the Twitch API.
Variables ¶
This section is empty.
Functions ¶
func GetStream ¶
func GetStream(client *http.Client, channelName, accessToken, streamQuality string) (*m3u8.Variant, error)
GetStream will load the stream details for the provided channel name. The streamQuality parameter should be either audio_only or a target video resolution.
func InitEnv ¶
func InitEnv(redisURL string)
InitEnv provides a package level initialization point for any work that is environment specific
func SaveUsersCurrentStream ¶
SaveUsersCurrentStream will append the provided stream's User ID to the list of recently played. The list is set to automatically expire after 24 hours. This expiration time will be updated on each stream start.
Types ¶
type ChannelAccessToken ¶
ChannelAccessToken is used for loading the stream URL for a specific channel. For some reason this type of request auth needs to be used instead of the other oauth process.
type Follow ¶
Follow describes a single follower relationship, FromID is the user doing the following and ToID is the user being followed.
type Follows ¶
type Follows struct {
Data []*Follow
}
Follows is a wrapper around the response when requesting a set of follower relationships
func GetFollows ¶
GetFollows will load the following information for the provided Twitch user. The channels returned will be all of the channels followed by this user.
func (*Follows) FollowIDsList ¶
FollowIDsList will extract the user IDs from the calling Follows struct into a single slice
type Pagination ¶
type Pagination struct {
Cursor string `json:"cursor"`
}
Pagination wraps the cursor used to perform pagination on endpoints that support it. The cursor should be used in following requests to indicate the current page.
type PlaybackCommand ¶
type PlaybackCommand int
const ( PLAY PlaybackCommand = iota RESUME PAUSE PREVIOUS NEXT STOP )
type Stream ¶
type Stream struct { ID string `json:"id"` UserID string `json:"user_id"` CommunityIDs []string `json:"community_ids"` Type string `json:"type"` Title string `json:"title"` ViewerCount int `json:"viewer_count"` ThumbnailURL string `json:"thumbnail_url"` }
Stream describes the properties for a particular stream on Twitch
func FindStreamForCommand ¶
func FindStreamForCommand(user *User, liveStreams []*Stream, command PlaybackCommand, response *skillserver.EchoResponse) *Stream
type StreamsResponse ¶
type StreamsResponse struct { Data []*Stream *Pagination }
StreamsResponse container around the Twitch streams response.
func FindLiveStreams ¶
func FindLiveStreams(client *http.Client, uids []string) (*StreamsResponse, error)
FindLiveStreams will request the data for all currently live streams on Twitch for the provided list of user IDs.
type User ¶
type User struct { ID string `json:"id"` Login string `json:"login"` DisplayName string `json:"display_name"` Type string `json:"type"` BroadcasterType string `json:"broadcaster_type"` }
User contains all the properties for a particular Twitch user.
func GetUserByID ¶
GetUserByID will load details for the user specified by the provided id. If the ID is the empty string, the current user will be determined from the provided access token.
type UserResponse ¶
type UserResponse struct {
Data []*User
}
UserResponse is a container around the response from the Twitch /users endpoint