gfycat

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2017 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// BaseURI represents GFYCat's API URL
	BaseURI = "https://api.gfycat.com/v1"
)

Variables

This section is empty.

Functions

func ToJSON

func ToJSON(t interface{}) (io.Reader, error)

ToJSON will encode an object to it's JSON representation and provide it as a io.Reader

Types

type APIResponse

type APIResponse http.Response

APIResponse represents an HTTP response from the GFYCat API

func (*APIResponse) ToType

func (gfy *APIResponse) ToType(destination interface{}) error

ToType will unmarshal a GfyCat API response into the provided object

type Caption

type Caption struct {
	Text               string  `json:"text"`
	StartSeconds       int     `json:"startSeconds"`
	Duration           int     `json:"duration"`
	FontHeight         int     `json:"fontHeight"`
	X                  int     `json:"x"`
	Y                  int     `json:"y"`
	FontHeightRelative float32 `json:"fontHeightRelative"`
	XRelatice          float32 `json:"xRelative"`
	YRelative          float32 `json:"yRelative"`
}

Caption represents in-gif captions

type Crop

type Crop struct {
	X int `json:"x"`
	Y int `json:"y"`
	W int `json:"w"`
	H int `json:"h"`
}

Crop represents the dimensions of the reduced GFYCat

type Cut

type Cut struct {
	Duration int `json:"duration"`
	Start    int `json:"start"`
}

Cut represents the total duration of the processed video, and where to start trimming from

type FileDrop

type FileDrop struct {
	GfyName string `json:"gfyname"`
	Secret  string `json:"secret"`
}

FileDrop represents an inflight upload

type GFYAccessToken

type GFYAccessToken struct {
	TokenType string    `json:"token_type"`
	Scope     string    `json:"scope"`
	Expires   int       `json:"expires_in"`
	Token     string    `json:"access_token"`
	Created   time.Time `json:"-"`
}

GFYAccessToken represents an exchanged OAuth token

type GFYClient

type GFYClient struct {
	Grant *GFYClientGrant
	Token *GFYAccessToken
	// contains filtered or unexported fields
}

GFYClient represents an authenticated request dispatcher to the GFYCat API

func NewGFYClient

func NewGFYClient(grant *GFYClientGrant) (*GFYClient, error)

NewGFYClient accepts a grant and returns an authenticated client

func (*GFYClient) LocalUpload

func (gfy *GFYClient) LocalUpload(Filepath string, Upload *UploadFile) (*FileDrop, error)

LocalUpload uploads a local file to GFYCat

func (*GFYClient) UploadStatus

func (gfy *GFYClient) UploadStatus(activeUpload *FileDrop) (*UploadStatus, error)

UploadStatus provides updates on the processing status of a file

type GFYClientGrant

type GFYClientGrant struct {
	ClientID     string `json:"client_id"`
	ClientSecret string `json:"client_secret"`
	GrantType    string `json:"grant_type"`
	Username     string `json:"username,omitempty"`
	Password     string `json:"password,omitempty"`
}

GFYClientGrant represents the locally stored API OAuth client credentials

func NewClientGrantFromFile

func NewClientGrantFromFile(path string) (*GFYClientGrant, error)

NewClientGrantFromFile loads a file and returns a GFYClientGrant

func (*GFYClientGrant) Exchange

func (gfy *GFYClientGrant) Exchange() (*GFYAccessToken, error)

Exchange turns local credentials into an active token

type UploadError

type UploadError struct {
	Code        string `json:"code"`
	Description string `json:"description"`
}

UploadError represents an upload error message

type UploadFile

type UploadFile struct {
	FetchURL     string    `json:"fetchUrl,omitempty"`
	Title        string    `json:"title,omitempty"`
	Description  string    `json:"description,omitempty"`
	Tags         []string  `json:"tags,omitempty"`
	NoMd5        bool      `json:"noMd5,omitempty"`
	Private      int       `json:"private,omitempty"`
	Nsfw         int       `json:"nsfw,omitempty"`
	FetchSeconds int       `json:"fetchSeconds,omitempty"`
	FetchMinutes int       `json:"fetchMinutes,omitempty"`
	FetchHours   int       `json:"fetchHours,omitempty"`
	Captions     []Caption `json:"captions,omitempty"`
	Cut          []Cut     `json:"cut,omitempty"`
	Crop         []Crop    `json:"crop,omitempty"`
}

UploadFile represents the structure of an UploadFile request

type UploadStatus

type UploadStatus struct {
	// While encoding or not found
	Task     string  `json:"task"`
	Time     int     `json:"time"`
	Progress float32 `json:"progress,string"`

	// When complete
	GfyName string `json:"gfyname"`

	// If Errored
	ErrorMessage UploadError `json:"errorMessage"`
}

UploadStatus represents an inflight upload status response

Jump to

Keyboard shortcuts

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