cas

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

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

Go to latest
Published: Aug 9, 2017 License: BSD-2-Clause Imports: 8 Imported by: 0

README

TwitCasting API v2 Client in Go

cas is a half-baked Go client library for the TwitCasting API v2.

Installing

go get github.com/nobuf/cas

Example

Getting User Information
package main

import (
	"github.com/nobuf/cas"
	"log"
)

func main() {
	api := cas.New("your-client-id", "your-client-secret")
	u, err := api.User("twitcasting_jp")
	if err != nil {
		log.Fatal(err)
	}
	log.Printf("%+v\n", u)
}

See other examples in the examples folder. You can generate your client id and secret via the Developer page.

Contributing

All are welcome :)

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TwitCastingAPI = "https://apiv2.twitcasting.tv"

TwitCastingAPI is the endpoint of API. It's possible to override it, or use SetEndpoint().

Functions

This section is empty.

Types

type CategoriesContainer

type CategoriesContainer struct {
	Categories []Category `json:"categories"`
}

CategoriesContainer holds a list of Categories

type Category

type Category struct {
	ID            string        `json:"id"`
	Name          string        `json:"name"`
	SubCategories []SubCategory `json:"sub_categories"`
}

Category such as "声"

type Client

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

Client is the main struct to access all the methods that this package provides.

func New

func New(clientID string, clientSecret string) *Client

New initializes Client. TODO support OAuth token

func (*Client) Categories

func (api *Client) Categories() (*CategoriesContainer, error)

Categories returns a list of Categories and its SubCategories

func (*Client) Comments

func (api *Client) Comments(id MovieID, p *CommentsOption) (*CommentsContainer, error)

Comments retrieves Comments by the given MovieID.

func (*Client) DefaultCommentsOption

func (api *Client) DefaultCommentsOption() *CommentsOption

DefaultCommentsOption returns a CommentsOption with default values.

func (*Client) DefaultUserMoviesOption

func (api *Client) DefaultUserMoviesOption() *UserMoviesOption

DefaultUserMoviesOptions returns a UserMoviesOption with default values.

func (*Client) Movie

func (api *Client) Movie(id MovieID) (*MovieContainer, error)

Movie retrieves a Movie object by the given MovieID.

func (*Client) RecommendedLives

func (api *Client) RecommendedLives() (*Movies, error)

RecommendedLives retrieves recommended Moves on live. See http://apiv2-doc.twitcasting.tv/#search-live-movies

func (*Client) SearchLives

func (api *Client) SearchLives(p *SearchLivesOptions) (*Movies, error)

SearchLives retrieves Movies based on the given parameters.

func (*Client) SearchLivesByTags

func (api *Client) SearchLivesByTags(tags []string) (*Movies, error)

SearchLivesByTags retrieves Movies by tag(s).

func (*Client) SearchUsers

func (api *Client) SearchUsers(p *SearchUsersOptions) (*UsersContainer, error)

SearchUsers retrieves Users by the given parameters.

func (*Client) SearchUsersByWords

func (api *Client) SearchUsersByWords(words []string) (*UsersContainer, error)

SearchUsersByWords retrieves Users by the given word(s).

func (*Client) SetEndpoint

func (api *Client) SetEndpoint(endpoint string)

SetEndpoint overrides the API host and the root path.

func (*Client) User

func (api *Client) User(id string) (*UserContainer, error)

User retrieves a User object by the given user id

func (*Client) UserMovies

func (api *Client) UserMovies(id string, p *UserMoviesOption) (*UserMovies, error)

UserMovies retrieves Movies by the given user id.

type Comment

type Comment struct {
	ID      string `json:"id"`
	Message string `json:"message"`
	From    User   `json:"from_user"`
	Created int    `json:"created"`
}

Comment object.

type CommentsContainer

type CommentsContainer struct {
	MovieID  MovieID   `json:"movie_id"`
	Count    int       `json:"all_count"`
	Comments []Comment `json:"comments"`
}

CommentsContainer contains a list of Comments and other information.

type CommentsOption

type CommentsOption struct {
	Offset int    `url:"offset"`
	Limit  int    `url:"limit"`
	Since  string `url:"since_id"`
}

CommentsOption are the parameters for getting Comments.

type Movie

type Movie struct {
	ID               MovieID `json:"id"`
	UserID           string  `json:"user_id"`
	Title            string  `json:"title"`
	Subtitle         string  `json:"subtitle"`
	LastOwnerComment string  `json:"last_owner_comment"`
	Link             string  `json:"link"`
	Live             bool    `json:"is_live"`
	Recorded         bool    `json:"is_recorded"`
	CommentCount     int     `json:"comment_count"`
	LargeThumbnail   string  `json:"large_thumbnail"`
	SmallThumbnail   string  `json:"small_thumbnail"`
	Country          string  `json:"country"`
	Duration         int     `json:"duration"`
	Created          int     `json:"created"`
	Collabo          bool    `json:"is_collabo"`
	Protected        bool    `json:"is_protected"`
	MaxViewCount     int     `json:"max_view_count"`
	CurrentViewCount int     `json:"current_view_count"`
	TotalViewCount   int     `json:"total_view_count"`
	HLS              string  `json:"hls_url"`
}

Movie object. See http://apiv2-doc.twitcasting.tv/#get-movie-info

type MovieContainer

type MovieContainer struct {
	Movie       Movie    `json:"movie"`
	Broadcaster User     `json:"broadcaster"`
	Tags        []string `json:"tags"`
}

MovieContainer holds Movie and its related data.

type MovieID

type MovieID string

MovieID is identifier of a Movie object. In the TwitCasting world, it's sequential digits.

func (MovieID) Equal

func (id MovieID) Equal(a MovieID) bool

Equal returns true if two IDs are identical.

func (MovieID) GreaterThan

func (id MovieID) GreaterThan(a MovieID) bool

GreaterThan return true if the source MovieID is greater than the given ID, that means it is newer than the given ID.

func (MovieID) Int

func (id MovieID) Int() int

Int converts MovieID to int.

func (MovieID) String

func (id MovieID) String() string

String returns MovieID in string.

type Movies

type Movies struct {
	Movies []MovieContainer `json:"movies"`
}

Movies is a slice of MovieContainers.

type SearchLivesOptions

type SearchLivesOptions struct {
	Limit   int    `url:"limit"`
	Type    string `url:"type"`
	Context string `url:"context"`
	Lang    string `url:"lang"`
}

SearchLivesOptions are the parameters for the Search Live Movies API.

type SearchUsersOptions

type SearchUsersOptions struct {
	Words string `url:"words"`
	Limit int    `url:"limit"`
	Lang  string `url:"lang"`
}

SearchUsersOptions are the parameters for searching Users.

type SubCategory

type SubCategory struct {
	ID   string `json:"id"`
	Name string `json:"name"`

	// Number of current live Movies
	Count int `json:"count"`
}

SubCategory such as "イケボ(男子)" in the "声" category

type User

type User struct {
	ID          string  `json:"id"`
	ScreenID    string  `json:"screen_id"`
	Name        string  `json:"name"`
	Image       string  `json:"image"`
	Profile     string  `json:"profile"`
	Level       int     `json:"level"`
	LastMovieID MovieID `json:"last_movie_id"`
	Live        bool    `json:"is_live"`
	Created     int     `json:"created"`
}

User object See http://apiv2-doc.twitcasting.tv/#get-user-info

type UserContainer

type UserContainer struct {
	User User `json:"user"`
}

UserContainer holds a User object

type UserMovies

type UserMovies struct {
	Movies []Movie `json:"movies"`
}

UserMovies is a slice of Movie objects.

type UserMoviesOption

type UserMoviesOption struct {
	Offset int `url:"offset"`
	Limit  int `url:"limit"`
}

UserMoviesOption is a collection of parameters for getting UserMovies.

type UsersContainer

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

UsersContainer holds a list of Users

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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