twitch

package
v0.0.0-...-2bc52ac Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2017 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessTokenS

type AccessTokenS struct {
	Sig              string `json:"sig,omitempty"`
	MobileRestricted bool   `json:"mobile_restricted"`
	Token            string `json:"token,omitempty"`
}

type AppInfo

type AppInfo struct {
	ClientID     string `url:"client_id"`
	ClientSecret string `url:"client_secret"`
	State        string `url:"state"`
	RedirectURI  string `url:"redirect_uri"`
	Scope        string `url:"scope"`
}

type AuthMethods

type AuthMethods struct {
	AccessToken string
	// contains filtered or unexported fields
}

func (*AuthMethods) LoginCallback

func (a *AuthMethods) LoginCallback(w http.ResponseWriter, r *http.Request) (*OAuthResponse, error)

func (*AuthMethods) OAuthRedirect

func (a *AuthMethods) OAuthRedirect(w http.ResponseWriter, r *http.Request)

type BlockS

type BlockS struct {
	User UserS `json:"user,omitempty"`
	Id   int   `json:"_id,omitempty"`
}

type BlocksS

type BlocksS struct {
	Blocks []BlockS `json:"blocks,omitempty"`
	Links  LinksS   `json:"_links,omitempty"`
}

type ChannelLinksS

type ChannelLinksS struct {
	Chat         string `json:"chat,omitempty"`
	Commercial   string `json:"commercial,omitempty"`
	Videos       string `json:"videos,omitempty"`
	Teams        string `json:"teams,omitempty"`
	Editors      string `json:"editors,omitempty"`
	Subsciptions string `json:"subscriptions,omitempty"`
	Features     string `json:"features,omitempty"`
	StreamKey    string `json:"stream_key,omitempty"`
	Follows      string `json:"follows,omitempty"`
}

type ChannelNS

type ChannelNS struct {
	Name                         string        `json:"name,omitempty"`
	Status                       string        `json:"status,omitempty"`
	Game                         string        `json:"game,omitempty"`
	Delay                        int           `json:"delay,omitempty"`
	Id                           int           `json:"_id,omitempty"`
	CreatedAt                    string        `json:"created_at,omitempty"`
	UpdatedAt                    string        `json:"updated_at,omitempty"`
	PrimaryTeamName              string        `json:"primary_team_name,omitempty"`
	PrimaryTeamDisplayName       string        `json:"primary_team_display_name,omitempty"`
	Teams                        []TeamS       `json:"teams,omitempty"`
	Title                        string        `json:"title,omitempty"`
	Mature                       bool          `json:"mature,omitempty"`
	AbuseReported                bool          `json:"abuse_reported,omitempty"`
	Banner                       string        `json:"banner,omitempty"`
	VideoBanner                  string        `json:"video_banner,omitempty"`
	Views                        int           `json:"views,omitempty"`
	Followers                    int           `json:"followers,omitempty"`
	Background                   string        `json:"background,omitempty"`
	ProfileBanner                string        `json:"profile_banner,omitempty"`
	ProfileBannerBackgroundColor string        `json:"profile_banner_background_color,omitempty"`
	Links                        ChannelLinksS `json:"_links,omitempty"`
	Url                          string        `json:"url,omitempty"`
	DisplayName                  string        `json:"display_name,omitempty"`
	Language                     string        `json:"language,omitempty"`
	BroadcasterLanguage          string        `json:"broadcaster_language,omitempty"`
	// authenticated
	StreamKey string `json:"stream_key,omitempty"`
	Login     string `json:"login,omitempty"`
	Email     string `json:"email,omitempty"`
}

Channel object - Number ID

type ChannelS

type ChannelS struct {
	Name                         string        `json:"name,omitempty"`
	Status                       string        `json:"status,omitempty"`
	Game                         string        `json:"game,omitempty"`
	Delay                        int           `json:"delay,omitempty"`
	Id                           string        `json:"_id,omitempty"`
	CreatedAt                    string        `json:"created_at,omitempty"`
	UpdatedAt                    string        `json:"updated_at,omitempty"`
	PrimaryTeamName              string        `json:"primary_team_name,omitempty"`
	PrimaryTeamDisplayName       string        `json:"primary_team_display_name,omitempty"`
	Teams                        []TeamS       `json:"teams,omitempty"`
	Title                        string        `json:"title,omitempty"`
	Mature                       bool          `json:"mature,omitempty"`
	AbuseReported                bool          `json:"abuse_reported,omitempty"`
	Banner                       string        `json:"banner,omitempty"`
	VideoBanner                  string        `json:"video_banner,omitempty"`
	Views                        int           `json:"views,omitempty"`
	Followers                    int           `json:"followers,omitempty"`
	Background                   string        `json:"background,omitempty"`
	ProfileBanner                string        `json:"profile_banner,omitempty"`
	ProfileBannerBackgroundColor string        `json:"profile_banner_background_color,omitempty"`
	Links                        ChannelLinksS `json:"_links,omitempty"`
	Url                          string        `json:"url,omitempty"`
	DisplayName                  string        `json:"display_name,omitempty"`
	Language                     string        `json:"language,omitempty"`
	BroadcasterLanguage          string        `json:"broadcaster_language,omitempty"`
	// authenticated
	StreamKey string `json:"stream_key,omitempty"`
	Login     string `json:"login,omitempty"`
	Email     string `json:"email,omitempty"`
}

Channel object - String ID

type ChannelsMethod

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

func (*ChannelsMethod) AccessToken

func (c *ChannelsMethod) AccessToken(name string) (*AccessTokenS, error)

func (*ChannelsMethod) Channel

func (c *ChannelsMethod) Channel(name string) (*ChannelS, error)

Returns a channel object. If `name` is an empty string, returns the channel object of authenticated user.

func (*ChannelsMethod) Follows

func (c *ChannelsMethod) Follows(name string, opt *ListOptions) (*FollowsS, error)

Returns a list of users the channel `name` is following.

func (*ChannelsMethod) M3U8

func (c *ChannelsMethod) M3U8(name string, opt *M3U8Options) (string, error)

func (*ChannelsMethod) Panels

func (c *ChannelsMethod) Panels(name string, opt *ListOptions) (*[]PanelS, error)

Returns the list of panels the channel `name` has.

func (*ChannelsMethod) Videos

func (c *ChannelsMethod) Videos(name string, opt *ListOptions) (*VideosS, error)

Returns a list of videos ordered by time of creation, starting with the most recent from channel `name`.

type ChatLinks struct {
	Links ChatLinksS `json:"_links,omitempty"`
}

type ChatLinksS

type ChatLinksS struct {
	Emoticons string `json:"emoticons,omitempty"`
	Badges    string `json:"badges,omitempty"`
}

type ChatMethod

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

func (*ChatMethod) Emoticons

func (c *ChatMethod) Emoticons() (*EmoticonsS, error)

type Client

type Client struct {
	BaseURL     *url.URL
	AppInfo     *AppInfo
	AccessToken string

	// Twitch api methods
	Channels *ChannelsMethod
	Chat     *ChatMethod
	Games    *GamesMethod
	Ingests  *IngestsMethod
	Search   *SearchMethod
	Streams  *StreamsMethod
	Teams    *TeamsMethod
	Users    *UsersMethod
	Videos   *VideosMethod

	// OAuth
	Auth          *AuthMethods
	OAuthResponse *OAuthResponse
	// contains filtered or unexported fields
}

func NewClient

func NewClient(httpClient *http.Client) *Client

Returns a new twitch client used to communicate with the API.

func (*Client) Get

func (c *Client) Get(path string, r interface{}) (*http.Response, error)

Issues an API get request and returns the API response. The response body is decoded and stored in the value pointed by r.

func (*Client) GetAPI

func (c *Client) GetAPI(path string, r interface{}) (*http.Response, error)

Issues an API get request and returns the API response. The response body is decoded and stored in the value pointed by r.

func (*Client) GetUsher

func (c *Client) GetUsher(path string) (string, error)

Issues an API get request and returns the API response. The response body is decoded and stored in the value pointed by r.

type EditorsS

type EditorsS struct {
	Users []UserS `json:"users,omitempty"`
	Links LinksS  `json:"_links,omitempty"`
}

used with GET /channels/:channel/editors

type EmoticonS

type EmoticonS struct {
	Regex  string   `json:"regex,omitempty"`
	Images []ImageS `json:"images,omitempty"`
}

type EmoticonsS

type EmoticonsS struct {
	Emoticons []EmoticonS `json:"emoticons,omitempty"`
}

type FStreamS

type FStreamS struct {
	Stream StreamS `json:"stream,omitempty"`
	Text   string  `json:"text,omitempty"`
	Image  string  `json:"image,omitempty"`
}

type FeaturedS

type FeaturedS struct {
	Featured []FStreamS `json:"featured,omitempty"`
}

used with GET /streams/featured

type FollowS

type FollowS struct {
	User UserS `json:"user,omitempty"`
}

type FollowedS

type FollowedS struct {
	Streams []StreamS `json:"streams,omitempty"`
}

used with GET /streams/followed

type FollowsS

type FollowsS struct {
	Follows []FollowS `json:"follows,omitempty"`
	Total   int       `json:"_total,omitempty"`
	Links   LinksS    `json:"_links,omitempty"`
}

used with GET /channels/:channel/follows

type GameS

type GameS struct {
	Name        string   `json:"name,omitempty"`
	Box         PreviewS `json:"box,omitempty"`
	Id          int      `json:"_id,omitempty"`
	GiantbombId int      `json:"giantbomb_id,omitempty"`
}

type GamesMethod

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

func (*GamesMethod) Top

func (g *GamesMethod) Top(opt *ListOptions) (*TopsS, error)

Returns a list of games objects sorted by number of current viewers, most popular first.

type ImageS

type ImageS struct {
	EmoticonSet int    `json:"emoticon_set,omitempty"`
	Height      int    `json:"height,omitempty"`
	Width       int    `json:"width,omitempty"`
	Url         string `json:"url,omitempty"`
}

type ImagesS

type ImagesS struct {
	Thumb  string `json:"thumb,omitempty"`
	Tiny   string `json:"tiny,omitempty"`
	Small  string `json:"small,omitempty"`
	Super  string `json:"super,omitempty"`
	Medium string `json:"medium,omitempty"`
	Icon   string `json:"icon,omitempty"`
	Screen string `json:"screen,omitempty"`
}

type IngestS

type IngestS struct {
	Name         string  `json:"name,omitempty"`
	Default      bool    `json:"default,omitempty"`
	Id           int     `json:"_id,omitempty"`
	UrlTemplate  string  `json:"url_template,omitempty"`
	Availability float64 `json:"availability,omitempty"`
}

type IngestsMethod

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

func (*IngestsMethod) List

func (i *IngestsMethod) List() (*IngestsS, error)

type IngestsS

type IngestsS struct {
	Ingests []IngestS `json:"ingests,omitempty"`
}

type LinksS

type LinksS struct {
	Next string `json:"next,omitempty"`
}

type ListOptions

type ListOptions struct {
	Game       string `url:"game,omitempty"`
	Channel    string `url:"channel,omitempty"`
	Direction  string `url:"direction,omitempty"`
	Period     string `url:"period,omitempty"`
	Limit      int    `url:"limit,omitempty"`
	Offset     int    `url:"offset,omitempty"`
	Embeddable *bool  `url:"embeddable,omitempty"`
	Hls        *bool  `url:"hls,omitempty"`
	Live       *bool  `url:"live,omitempty"`
}

type M3U8Options

type M3U8Options struct {
	Token          string `url:"token,omitempty"`
	Sig            string `url:"sig,omitempty"`
	Player         string `url:"player,omitempty"`
	AllowAudioOnly bool   `url:"$allow_audio_only"`
	AllowSource    bool   `url:"allow_source"`
	Type           string `url:"type,omitempty"`
	Random         int    `url:"p,omitempty"`
}

type OAuthCallback

type OAuthCallback func(http.ResponseWriter, *http.Request) (*OAuthResponse, error)

type OAuthResponse

type OAuthResponse struct {
	AccessToken  string   `json:"access_token"`
	RefreshToken string   `json:"refresh_token"`
	Scope        []string `json:"scope"`
}

type PanelDataS

type PanelDataS struct {
	Link        string `json:"link,omitempty"`
	Image       string `json:"image,omitempty"`
	Title       string `json:"title,omitempty"`
	Description string `json:"description,omitempty"`
}

type PanelS

type PanelS struct {
	Id              int        `json:"_id,omitempty"`
	DisplayOrder    int        `json:"display_order,omitempty"`
	Kind            string     `json:"kind,omitempty"`
	HtmlDescription string     `json:"html_description,omitempty"`
	UserId          int        `json:"user_id,omitempty"`
	Data            PanelDataS `json:"data,omitempty"`
	Channel         string     `json:"channel,omitempty"`
}

type PreviewS

type PreviewS struct {
	Small    string `json:"small,omitempty"`
	Medium   string `json:"medium,omitempty"`
	Large    string `json:"large,omitempty"`
	Template string `json:"template,omitempty"`
}

type SChannelS

type SChannelS struct {
	Stream StreamS `json:"stream,omitempty"`
}

used with GET /streams/:channel/

type SGameS

type SGameS struct {
	Box         PreviewS `json:"box,omitempty"`
	Images      ImagesS  `json:"images,omitempty"`
	Popularity  int      `json:"popularity,omitempty"`
	Name        string   `json:"name,omitempty"`
	Id          int      `json:"_id,omitempty"`
	GiantbombId int      `json:"giantbomb_id,omitempty"`
}

type SGamesS

type SGamesS struct {
	Games []SGameS `json:"games,omitempty"`
}

type SearchMethod

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

func (*SearchMethod) Games

func (s *SearchMethod) Games(q string, opt *ListOptions) (*SGamesS, error)

func (*SearchMethod) Streams

func (s *SearchMethod) Streams(q string, opt *ListOptions) (*StreamsNS, error)

type StreamNS

type StreamNS struct {
	Id      int       `json:"_id,omitempty"`
	Game    string    `json:"game,omitempty"`
	Preview PreviewS  `json:"preview,omitempty"`
	Viewers int       `json:"viewers,omitempty"`
	Channel ChannelNS `json:"channel,omitempty"`
}

Stream oject - ID as number

type StreamS

type StreamS struct {
	Id      string   `json:"_id,omitempty"`
	Game    string   `json:"game,omitempty"`
	Preview PreviewS `json:"preview,omitempty"`
	Viewers int      `json:"viewers,omitempty"`
	Channel ChannelS `json:"channel,omitempty"`
}

Stream oject - ID as string

type StreamsMethod

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

func (*StreamsMethod) Channel

func (s *StreamsMethod) Channel(name string) (*SChannelS, error)

Returns a stream object if live.

func (*StreamsMethod) Featured

func (s *StreamsMethod) Featured(opt *ListOptions) (*FeaturedS, error)

Returns a list of featured (promoted) stream objects.

func (*StreamsMethod) List

func (s *StreamsMethod) List(opt *ListOptions) (*StreamsNS, error)

Returns a list of stream objects according to optional parameters.

func (*StreamsMethod) Summary

func (s *StreamsMethod) Summary(opt *ListOptions) (*SummaryS, error)

Returns a summary of current streams.

type StreamsNS

type StreamsNS struct {
	Total   int        `json:"_total,omitempty"`
	Streams []StreamNS `json:"streams,omitempty"`
}

used with GET /streams

type StreamsS

type StreamsS struct {
	Total   int       `json:"_total,omitempty"`
	Streams []StreamS `json:"streams,omitempty"`
}

type SubS

type SubS struct {
	Id   string `json:"_id,omitempty"`
	User UserS  `json:"user,omitempty"`
}

type SubsS

type SubsS struct {
	Total         int    `json:"_total,omitempty"`
	Links         LinksS `json:"_links,omitempty"`
	Subscriptions []SubS `json:"subscriptions,omitempty"`
}

type SummaryS

type SummaryS struct {
	Viewers  int `json:"viewers,omitempty"`
	Channels int `json:"channels,omitempty"`
}

used with GET /streams/summary

type TeamS

type TeamS struct {
	Id          int    `json:"_id,omitempty"`
	Name        string `json:"name,omitempty"`
	Background  string `json:"background,omitempty"`
	Banner      string `json:"banner,omitempty"`
	Info        string `json:"info,omitempty"`
	DisplayName string `json:"display_name,omitempty"`
	CreatedAt   string `json:"created_at,omitempty"`
	UpdatedAt   string `json:"updated_at,omitempty"`
}

Team object

type TeamsMethod

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

func (*TeamsMethod) List

func (t *TeamsMethod) List(opt *ListOptions) (*TeamsS, error)

func (*TeamsMethod) Team

func (t *TeamsMethod) Team(name string) (*TeamS, error)

type TeamsS

type TeamsS struct {
	Teams []TeamS `json:"teams,omitempty"`
	Links LinksS  `json:"_links,omitempty"`
}

type TopS

type TopS struct {
	Game     GameS `json:"game,omitempty"`
	Viewers  int   `json:"viewers,omitempty"`
	Channels int   `json:"channels,omitempty"`
}

type TopsS

type TopsS struct {
	Links LinksS `json:"_links,omitempty"`
	Total int    `json:"_total,omitempty"`
	Top   []TopS `json:"top,omitempty"`
}

type UAuthedS

type UAuthedS struct {
	UserS
	Email         string         `json:"email,omitempty"`
	Partnered     bool           `json:"partnered,omitempty"`
	Notifications UNotificationS `json:"notifications,omitempty"`
}

type UFollowS

type UFollowS struct {
	Channel ChannelS `json:"channel,omitempty"`
}

type UFollowsS

type UFollowsS struct {
	Follows []UFollowS `json:"follows,omitempty"`
	Links   LinksS     `json:"_links,omitempty"`
	Total   int        `json:"_total,omitempty"`
}

type UNotificationS

type UNotificationS struct {
	Push  bool `json:"push,omitempty"`
	Email bool `json:"email,omitempty"`
}

type UTargetS

type UTargetS struct {
	Channel   ChannelNS `json:"channel,omitempty"`
	CreatedAt string    `json:"created_at,omitempty"`
}

type UserS

type UserS struct {
	Name        string    `json:"name,omitempty"`
	Id          string    `json:"_id,omitempty"`
	DisplayName string    `json:"display_name,omitempty"`
	Type        string    `json:"type,omitempty"`
	Bio         string    `json:"bio,omitempty"`
	CreatedAt   time.Time `json:"created_at,omitempty"`
	UpdatedAt   time.Time `json:"updated_at,omitempty"`
}

User object

type UsersMethod

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

func (*UsersMethod) Authenticated

func (u *UsersMethod) Authenticated() (*UAuthedS, error)

User returns a user object.

func (*UsersMethod) Follow

func (u *UsersMethod) Follow(user, target string) (*UTargetS, error)

Get status of follow relationship between user and target channel

func (*UsersMethod) Follows

func (u *UsersMethod) Follows(user string, opt *ListOptions) (*UFollowsS, error)

Get a user's list of followed channels

func (*UsersMethod) User

func (u *UsersMethod) User(user string) (*UserS, error)

User returns a user object.

type VideoS

type VideoS struct {
	Title string `json:"title,omitempty"`
	Id    string `json:"_id,omitempty"`
	// Embed       string        `json:"embed,omitempty"`
	Url         string   `json:"url,omitempty"`
	Views       int      `json:"views,omitempty"`
	Preview     PreviewS `json:"preview,omitempty"`
	Length      int      `json:"length,omitempty"`
	Description string   `json:"description,omitempty"`
	BroadcastId int      `json:"broadcast_id"`
	RecordedAt  string   `json:"recorded_at,omitempty"`
	Game        string   `json:"game,omitempty"`
	Channel     ChannelS `json:"channel,omitempty"`
}

Video object

type VideosMethod

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

func (*VideosMethod) Id

func (v *VideosMethod) Id(id string) (*VideoS, error)

func (*VideosMethod) Top

func (v *VideosMethod) Top(opt *ListOptions) (*VideosS, error)

type VideosS

type VideosS struct {
	Videos []VideoS `json:"videos,omitempty"`
	Links  LinksS   `json:"_links,omitempty"`
}

used with GET /channels/:channel/videos

Jump to

Keyboard shortcuts

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