vimego

package module
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2023 License: ISC Imports: 8 Imported by: 0

README

Vimego

Vimego is a simple Vimeo Go client.

Usage

Functions
c := vimego.New{accessToken: "YOUR_ACCESS_TOKEN"}

json, err := c.ListMyProjects()
json, err := c.ListProjectsOfUser(1234)
json, err := c.GetMyProject(4567)
json, err := c.GetProjectOfUser(1234, 4567)
json, err := c.ListMyProjectVideos(4567)
json, err := c.ListProjectVideosOfUser(1234, 4567)

json, err := c.GetVideo(8910)
json, err := c.GetVideoTexttracks(8910)
Set parameters
json, err := c.ListMyProjects(Page(2), PerPage(25), Fields{"name", "uri"})

Examples

Pagination
page := 1
hasNextPage := true
for hasNextPage {
	json, err := c.ListMyProjects(Page(page), PerPage(25), Fields{"uri", "name"})
	if err != nil {
	    fmt.Println(err)	
    }   
	
	fmt.Println(json)
	
	hasNextPage = len(json.Paginate.Next) != 0
	page++
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	AccessToken string
	BaseURL     string
	HttpClient  *http.Client
}

func New

func New(accessToken string) *Client

func (*Client) GetMyProject

func (c *Client) GetMyProject(id int, params ...QueryParam) (*Project, error)

func (*Client) GetProjectOfUser

func (c *Client) GetProjectOfUser(u, id int, params ...QueryParam) (*Project, error)

func (*Client) GetVideo

func (c *Client) GetVideo(id int, params ...QueryParam) (*Video, error)

func (*Client) ListMyProjectVideos

func (c *Client) ListMyProjectVideos(id int, params ...QueryParam) (*VimeoResponse[Video], error)

func (*Client) ListMyProjects

func (c *Client) ListMyProjects(params ...QueryParam) (*VimeoResponse[Project], error)

func (*Client) ListProjectVideosOfUser

func (c *Client) ListProjectVideosOfUser(u, id int, params ...QueryParam) (*VimeoResponse[Video], error)

func (*Client) ListProjectsOfUser

func (c *Client) ListProjectsOfUser(u int, params ...QueryParam) (*VimeoResponse[Project], error)

func (*Client) ListVideoTexttracks

func (c *Client) ListVideoTexttracks(id int, params ...QueryParam) (*VimeoResponse[Texttrack], error)

type Error

type Error struct {
	StatusCode int
	URL        string
	Body       string
	RateLimit  RateLimit
}

func (Error) Error

func (e Error) Error() string

type Fields

type Fields []string

func (Fields) Get

func (f Fields) Get() (string, string)

type Page

type Page int

func (Page) Get

func (p Page) Get() (string, string)

type PerPage

type PerPage int

func (PerPage) Get

func (p PerPage) Get() (string, string)

type Project

type Project struct {
	CreatedTime             time.Time    `json:"created_time,omitempty"`
	ModifiedTime            time.Time    `json:"modified_time,omitempty"`
	LastUserActionEventDate time.Time    `json:"last_user_action_event_date,omitempty"`
	Name                    string       `json:"name,omitempty"`
	Privacy                 VimeoPrivacy `json:"privacy,omitempty"`
	ResourceKey             string       `json:"resource_key,omitempty"`
	URI                     string       `json:"uri,omitempty"`
	Link                    string       `json:"link,omitempty"`
	ManageLink              string       `json:"manage_link,omitempty"`
	PinnedOn                string       `json:"pinned_on"`
	IsPinned                bool         `json:"is_pinned,omitempty"`
	IsPrivateToUser         bool         `json:"is_private_to_user,omitempty"`
	User                    User         `json:"user,omitempty"`
	AccessGrant             string       `json:"access_grant,omitempty"`
}

func (Project) GetId

func (p Project) GetId() int

type QueryParam

type QueryParam interface {
	Get() (key, value string)
}

type RateLimit added in v0.4.0

type RateLimit struct {
	Limit     int
	Remaining int
	Reset     time.Time
}

type Texttrack

type Texttrack struct {
	Uri                string `json:"uri,omitempty"`
	Active             bool   `json:"active,omitempty"`
	Type               string `json:"type,omitempty"`
	Language           string `json:"language,omitempty"`
	DisplayLanguage    string `json:"display_language,omitempty"`
	Id                 int    `json:"id,omitempty"`
	Link               string `json:"link,omitempty"`
	LinkExpiresTime    int    `json:"link_expires_time,omitempty"`
	HLSLink            string `json:"hls_link,omitempty"`
	HLSLinkExpiresTime int    `json:"hls_link_expires_time,omitempty"`
	Name               string `json:"name,omitempty"`
}

type User

type User struct {
	Uri  string `json:"uri,omitempty"`
	Name string `json:"name,omitempty"`
}

type Video

type Video struct {
	URI         string        `json:"uri,omitempty"`
	Name        string        `json:"name,omitempty"`
	Description string        `json:"description,omitempty"`
	Type        string        `json:"type,omitempty"`
	Link        string        `json:"link,omitempty"`
	Duration    int           `json:"duration,omitempty"`
	Width       int           `json:"width,omitempty"`
	Height      int           `json:"height,omitempty"`
	Language    string        `json:"language,omitempty"`
	Options     VimeoOptions  `json:"options,omitempty"`
	Total       int           `json:"total,omitempty"`
	Files       []VimeoFile   `json:"files,omitempty"`
	Pictures    VimeoPictures `json:"pictures,omitempty"`
}

func (Video) GetId

func (v Video) GetId() int

type VimeoFile

type VimeoFile struct {
	Quality     string    `json:"quality,omitempty"`
	Rendition   string    `json:"rendition,omitempty"`
	Type        string    `json:"type,omitempty"`
	Width       int       `json:"width,omitempty"`
	Height      int       `json:"height,omitempty"`
	Link        string    `json:"link,omitempty"`
	CreatedTime time.Time `json:"created_time,omitempty"`
	FPS         int       `json:"fps,omitempty"`
	Size        int       `json:"size,omitempty"`
	MD5         string    `json:"md5,omitempty"`
	PublicName  string    `json:"public_name,omitempty"`
	SizeShort   string    `json:"size_short"`
}

type VimeoOptions

type VimeoOptions []string

type VimeoPaging

type VimeoPaging struct {
	Next     string `json:"next,omitempty"`
	Previous string `json:"previous,omitempty"`
	First    string `json:"first,omitempty"`
	Last     string `json:"last,omitempty"`
}

type VimeoPictures

type VimeoPictures struct {
	Uri      string      `json:"uri,omitempty"`
	Active   bool        `json:"active,omitempty"`
	Type     string      `json:"type,omitempty"`
	BaseLink string      `json:"base_link,omitempty"`
	Sizes    []VimeoSize `json:"sizes,omitempty"`
}

type VimeoPrivacy

type VimeoPrivacy struct {
	View string `json:"view,omitempty"`
}

type VimeoResponse

type VimeoResponse[T any] struct {
	Total   int         `json:"total,omitempty"`
	Page    int         `json:"page,omitempty"`
	PerPage int         `json:"per_page,omitempty"`
	Paging  VimeoPaging `json:"paging,omitempty"`
	Data    []T         `json:"data,omitempty"`
}

type VimeoSize

type VimeoSize struct {
	Width  int    `json:"width,omitempty"`
	Height int    `json:"height,omitempty"`
	Link   string `json:"link,omitempty"`
}

Jump to

Keyboard shortcuts

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