twitch

package module
v0.0.0-...-c37fae8 Latest Latest
Warning

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

Go to latest
Published: May 10, 2018 License: GPL-3.0 Imports: 9 Imported by: 1

README

go-twitch

Build Status Coverage Status GoDoc

Go library for accessing the new twitch API

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GetStreamInput

type GetStreamInput struct {
	After       string `url:"after,omitempty"`
	Before      string `url:"before,omitempty"`
	CommunityID string `url:"community_id,omitempty"`
	First       int    `url:"first,omitempty"`
	GameID      string `url:"game_id,omitempty"`
	Language    string `url:"language,omitempty"`
	Type        string `url:"type,omitempty"`
	UserID      string `url:"user_id,omitempty"`
	UserLogin   string `url:"user_login,omitempty"`
}

GetStreamInput adds filters to the GetStream function see GetStream for more information

type GetStreamer

type GetStreamer interface {
	GetStream(input GetStreamInput) (StreamList, error)
}

GetStreamer is a simple interface for the GetStream function

type GetUserInput

type GetUserInput struct {
	ID    string `url:"id,omitempty"`
	Login string `url:"login,omitempty"`
}

GetUserInput adds filters to the GetUser function

type HLSStream

type HLSStream struct {
	URL        string
	Quality    string
	Resolution string
	Bitrate    uint32
}

HLSStream shows information about a stream, URL is curl to an M3U6 playlist

type Interface

type Interface interface {
	GetStreamer
	StreamExtracter
}

Interface for the whole lib

type Pagination

type Pagination struct {
	Cursor string `json:"cursor"`
}

Pagination contains the cursor used for paginated results

type Session

type Session struct {
	BaseURL  string
	ClientID string
}

Session is a base struct for calling the other functions

func NewSession

func NewSession(clientID string) Session

NewSession creates a new Twitch Session

func (Session) ExtractStreamUrl

func (s Session) ExtractStreamUrl(name string) ([]HLSStream, error)

ExtractStreamUrl returns the lists of urls for each stream quality

func (Session) GetStream

func (s Session) GetStream(input GetStreamInput) (StreamList, error)

GetStream returns a list of Streams reference : https://dev.twitch.tv/docs/api/reference#get-streams

func (Session) GetUser

func (s Session) GetUser(input GetUserInput) (UserList, error)

GetUser returns a list of twitch user https://dev.twitch.tv/docs/api/reference#get-users

type Stream

type Stream struct {
	ID           string    `json:"id"`
	UserID       string    `json:"user_id"`
	GameID       string    `json:"game_id"`
	CommunityIds []string  `json:"community_ids"`
	Type         string    `json:"type"`
	Title        string    `json:"title"`
	ViewerCount  int       `json:"viewer_count"`
	StartedAt    time.Time `json:"started_at"`
	Language     string    `json:"language"`
	ThumbnailURL string    `json:"thumbnail_url"`
}

Stream is a livestream on Twitch

type StreamExtracter

type StreamExtracter interface {
	ExtractStreamUrl(name string) ([]HLSStream, error)
}

StreamExtracter is a simple interface for ExtractStreamUrl

type StreamList

type StreamList struct {
	Data []Stream   `json:"data"`
	Page Pagination `json:"pagination"`
}

StreamList is the list of stream outputted by GetStream

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"`
	Description     string `json:"description"`
	ProfileImageURL string `json:"profile_image_url"`
	OfflineImageURL string `json:"offline_image_url"`
	ViewCount       int    `json:"view_count"`
	Email           string `json:"email"`
}

User is a twitch User

type UserList

type UserList struct {
	Data []Stream   `json:"data"`
	Page Pagination `json:"pagination"`
}

UserList is the list of users outputted by GetStream

Jump to

Keyboard shortcuts

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