twitch2go

package module
v0.0.0-...-798219a Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2017 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ASC           Direction = "asc"
	DESC          Direction = "desc"
	CreatedAt     SortBy    = "created_at"
	LastBroadcast SortBy    = "last_broadcast"
	Login         SortBy    = "login"
	Views         VideoSort = "views"
	Time          VideoSort = "time"
)
View Source
const (
	ChatterEndpoint = "https://tmi.twitch.tv/group/user/%s/chatters"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Channel

type Channel struct {
	Mature                       bool        `json:"mature"`
	Status                       string      `json:"status"`
	BroadcasterLanguage          string      `json:"broadcaster_language"`
	DisplayName                  string      `json:"display_name"`
	Game                         string      `json:"game"`
	Language                     string      `json:"language"`
	ID                           json.Number `json:"_id,number"`
	Name                         string      `json:"name"`
	CreatedAt                    time.Time   `json:"created_at"`
	UpdatedAt                    time.Time   `json:"updated_at"`
	VideoBanner                  string      `json:"video_banner"`
	ProfileBanner                string      `json:"profile_banner"`
	ProfileBannerBackgroundColor string      `json:"profile_banner_background_color"`
	Partner                      bool        `json:"partner"`
	URL                          string      `json:"url"`
	Views                        uint        `json:"views"`
	Followers                    uint        `json:"followers"`
}

Channel Twitch Channel Data

type ChatterResponse

type ChatterResponse struct {
	ChatterCount uint     `json:"chatter_count"`
	Chatters     Chatters `json:"chatters"`
}

type Chatters

type Chatters struct {
	Moderators []string `json:"moderators"`
	Staff      []string `json:"staff"`
	Admins     []string `json:"admins"`
	GlobalMods []string `json:"global_mods"`
	Viewers    []string `json:"viewers"`
}

type Client

type Client struct {
	ClientID   string
	HTTPClient *http.Client
	// contains filtered or unexported fields
}

func NewClient

func NewClient(ClientID string) *Client

func (*Client) CheckUserFollowsChannel

func (c *Client) CheckUserFollowsChannel(userID string, channelID string) (*User, error)

CheckUserFollowsChannel will return the user object if the user is following the given channel. If no users and an error is returned, then the user is not following the channel.

func (*Client) CheckUserSubscriptionByChannel

func (c *Client) CheckUserSubscriptionByChannel(userID string, channelID string, oauth string) (*User, error)

CheckUserSubscriptionByChannel will return a user object if the given user is subscribed to the given channel. If no user and an error is returned, then either the user is not subscribed to the channel, or the channel does not have a subscription program.

func (*Client) GetChannelByID

func (c *Client) GetChannelByID(channelID string) (*Channel, error)

GetChannelByID will return a Channel object for the given channelID. Will return annotated errors.

func (*Client) GetChannelByOAuth

func (c *Client) GetChannelByOAuth(oauth string) (*Channel, error)

GetChannelByOAuth will return a Channel object for the given oauth. Will return annotated errors.

func (*Client) GetChannelEditors

func (c *Client) GetChannelEditors(channelID string, oauth string) (*[]User, error)

GetChannelEditors returns a list of Users that are editors for the given channel. Requires users oauth token.

func (*Client) GetChannelFollows

func (c *Client) GetChannelFollows(channelID string, cursor string, limit int, direction Direction) (*Followers, error)

GetChannelFollows returns a list of followers for the given channel. Since a channel can have thousands of followers, you must make multiple requests of smaller sizes.

The function takes four parameters:

channelID:
	The channel ID

cursor:
	Tells the server where to start fetching the next set of results, in a multi-page response.

limit:
	Number of records to return.  Maximum is 100, default is 25.

direction:
	Direction of sorting.  Valid values are `ASC`, and `DESC` (newest first).  Default is `DESC`.

func (*Client) GetChannelSubscriberByUser

func (c *Client) GetChannelSubscriberByUser(channelID string, userID string, oauth string) (*Subscription, error)

GetChannelSubscriberByUser will return the subscriber information if the user is subscribed to the channel.

func (*Client) GetChannelSubscribers

func (c *Client) GetChannelSubscribers(channelID string, oauth string, limit int, offset int, direction Direction) (*Subscribers, error)

GetChannelSubscribers returns a list of users that are subscribe to the channel.

Function takes five parameters:

channelID:
	ID of the Channel

oauth:
	User oauth token

limit:
	Maximum number of objects top return.  Default 25, Maximum 100.

direction:
	Sorting direction.  Valid values are `ASC` and `DESC`.  Default `ASC` (oldest first)

func (*Client) GetChannelVideos

func (c *Client) GetChannelVideos(channelID string, limit int, offset int, broadcastType string, language string, sort VideoSort) (*Videos, error)

GetChannelVideos returns a list of all videos on the given channel.

Function takes size parameters:

channelID:
	Channel ID

limit:
	Maximum number of objects to return.  Default 10, Maximum 100.

offset:
	The offset in the list to return.  If a list has more entries then the limit, the returned list will be a subset of the whole.  The offset lets you continue where you left off.

broadcastType:
	Comma separated list with any combination of `archive`, `highlight`, and `upload`.  Default is `highlight`.

language:
	Constrains the language of the videos returned.  For example `en,es`.  Default is all languages.

sort:
	Sorting order of returned videos.  Valid values `views` and `time`.  Default is `time` (most recent first).

func (*Client) GetChatters

func (c *Client) GetChatters(channel string) (*ChatterResponse, error)

GetChatters returns the chatters for the given channel

func (*Client) GetFollowedStreams

func (c *Client) GetFollowedStreams(oauth string) (*FollowedStream, error)

GetFollowedStreams returns a list of streams the user follows, based on user auth token.

func (*Client) GetStreamByChannel

func (c *Client) GetStreamByChannel(channelID string) (*Stream, error)

GetStreamByChannel returns a StreamResponse for the given channel

func (*Client) GetUserByID

func (c *Client) GetUserByID(userID string) (*User, error)

GetUserByID will return ther user for the given ID.

func (*Client) GetUserByOAuth

func (c *Client) GetUserByOAuth(oauth string) (*User, error)

GetUserByOauth returns a user from the given oauth token.

func (*Client) GetUserFollows

func (c *Client) GetUserFollows(userID string, limit int, offset int, direction Direction, sortBy SortBy) (*Followers, error)

GetUserFollows returns a list of channles the given user follows.

The function takes in five parameters:

userID:
	The User ID

limit:
	The number of channels to return.  Max is 100, default is 25.

offset:
	The offset in the list to return.  If a list has more entries then the limit, the returned list will be a subset of the whole.  The offset lets you continue where you left off.

direction:
	The direction of the returned list.  Values are `ASC` and `DESC` (newest first).  Default is `DESC`.

sortBy:
	The sort of the returned list.  Values are `CreatedAt`, `LastBroadcast`, and `Login`  Default is `CreatedAt`.

func (*Client) SearchChannels

func (c *Client) SearchChannels(channel string) (*[]Channel, error)

SearchChannels Searches for the given channel and returns the results

func (*Client) SearchExactChannel

func (c *Client) SearchExactChannel(channel string) (*Channel, error)

SearchExactChannel Searches for the given channel and returns the channel if the channel name is an exact match

func (*Client) SearchExactUser

func (c *Client) SearchExactUser(user string) (*User, error)

func (*Client) SearchUsers

func (c *Client) SearchUsers(user string) (*[]User, error)

type Direction

type Direction string

type Editors

type Editors struct {
	Users []User `json:"Users"`
}

type Error

type Error struct {
	Status  int
	Message string
}

Error represents a failure from the API.

func (*Error) Error

func (e *Error) Error() string

type Follow

type Follow struct {
	CreatedAt     time.Time         `json:"created_at"`
	Links         map[string]string `json:"_links"`
	Notifications bool              `json:"notifications"`
	User          User              `json:"user"`
	Channel       Channel           `json:"channel"`
}

Follower data for twitch channel

type FollowedStream

type FollowedStream struct {
	Total   uint     `json:"_total"`
	Streams []Stream `json:"streams"`
}

type Followers

type Followers struct {
	Total   uint     `json:"_total"`
	Cursor  string   `json:"_cursor"`
	Follows []Follow `json:"follows"`
}

type Fps

type Fps struct {
	Chunked float64 `json:"chunked"`
	High    float64 `json:"high"`
	Low     float64 `json:"low"`
	Medium  float64 `json:"medium"`
	Mobile  float64 `json:"mobile"`
}

type Notifications

type Notifications struct {
	Email bool `json:"email"`
	Push  bool `json:"push"`
}

type Post

type Post struct {
	ID        json.Number `json:"id,number"`
	CreatedAt time.Time   `json:"created_at"`
	Deleted   bool        `json:"deleted"`
	Emotes    []string    `json:"emotes"`
	Body      string      `json:"body"`
	User      User        `json:"user"`
}

type Preview

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

type Resolutions

type Resolutions struct {
	Chunked string `json:"chunked"`
	High    string `json:"high"`
	Low     string `json:"low"`
	Medium  string `json:"medium"`
	Mobile  string `json:"mobile"`
}

type ResponseError

type ResponseError struct {
	Error   string      `json:"error"`
	Message string      `json:"message"`
	Status  json.Number `json:"status,number"`
}

type Result

type Result struct {
	Totals   int64     `json:"_total"`
	Channels []Channel `json:"channels"`
}

type SortBy

type SortBy string

type Stream

type Stream struct {
	ID          json.Number `json:"_id,number"`
	Game        string      `json:"game"`
	CommunityID string      `json:"community_id"`
	Viewers     uint        `json:"viewers"`
	VideoHeight uint        `json:"video_height"`
	AverageFps  float64     `json:"average_fps"`
	Delay       uint        `json:"delay"`
	CreatedAt   time.Time   `json:"created_at"`
	IsPlaylist  bool        `json:"is_playlist"`
	Preview     Preview     `json:"preview"`
	Channel     Channel     `json:"channel"`
}

type StreamResponse

type StreamResponse struct {
	Stream Stream `json:"stream"`
}

type Subscribers

type Subscribers struct {
	Total         uint           `json:"_total"`
	Cursor        string         `json:"_cursor"`
	Subscriptions []Subscription `json:"subscriptions"`
}

type Subscription

type Subscription struct {
	ID        json.Number `json:"_id,number"`
	CreatedAt time.Time   `json:"created_at"`
	User      User        `json:"user"`
}

type Thumbnail

type Thumbnail struct {
	Type string `json:"type"`
	URL  string `json:"url"`
}

type Thumbnails

type Thumbnails struct {
	Large    []Thumbnail `json:"large"`
	Medium   []Thumbnail `json:"medium"`
	Small    []Thumbnail `json:"small"`
	Template []Thumbnail `json:"template"`
}

type User

type User struct {
	Type             string        `json:"type"`
	Name             string        `json:"name"`
	CreatedAt        time.Time     `json:"created_at"`
	UpdatedAt        time.Time     `json:"updated_at"`
	ID               json.Number   `json:"_id,number"`
	DisplayName      string        `json:"display_name"`
	Bio              string        `json:"bio"`
	Email            string        `json:"email"`
	EmailVerified    bool          `json:"email_verified"`
	Partnered        bool          `json:"partnered"`
	TwitterConnected bool          `json:"twitter_connected"`
	Notifications    Notifications `json:"notifications"`
}

User Twitch User Data

type UserSearchResult

type UserSearchResult struct {
	Total uint   `json:"_total"`
	Users []User `json:"users"`
}

type Video

type Video struct {
	ID              string      `json:"_id"`
	BroadcastID     json.Number `json:"broadcast_id,number"`
	BroadcastType   string      `json:"broadcast_type"`
	Channel         Channel     `json:"channel"`
	CreatedAt       time.Time   `json:"created_at"`
	Description     string      `json:"description"`
	DescriptionHTML string      `json:"description_html"`
	Fps             Fps         `json:"fps"`
	Game            string      `json:"game"`
	Language        string      `json:"language"`
	Length          uint        `json:"length"`
	Preview         Preview     `json:"preview"`
	PublishedAt     time.Time   `json:"published_at"`
	Resolutions     Resolutions `json:"resolutions"`
	Status          string      `json:"status"`
	TagList         string      `json:"tag_list"`
	Thumbnails      Thumbnails  `json:"thumbnails"`
	Title           string      `json:"title"`
	URL             string      `json:"url"`
	Viewable        string      `json:"viewable"`
	ViewableAt      interface{} `json:"viewable_at"`
	Views           uint        `json:"views"`
}

type VideoSort

type VideoSort string

type Videos

type Videos struct {
	Total  uint    `json:"_total"`
	Videos []Video `json:"videos"`
}

Jump to

Keyboard shortcuts

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