gofycat

package module
v0.0.0-...-97e2992 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2016 License: MIT Imports: 6 Imported by: 4

README

Gofycat

PLEASE NOT THAT A LOT OF ENDPOINTS DO NOT WORK. This will be resolved in the future. Please also note that a lot of functions just return a *http.Response, since Gfycat's api documentation is pretty lacking and I was unable to test a lot of it. Extended documentation will come later too.

Usage

package main

import ("github.com/Krognol/gofycat"
        "fmt"
       )

func main() {
    client_id := "your client id"
    client_secret := "your client secret"

    gfy := gofycat.New(client_id, client_secret, gofycat.Client)
    user, err := gfy.GetUser("Whatever username here")

    if err != nil {
        panic(err)
    }

    fmt.Println(user.URL)
    // >> https://gfycat.com/@whatever_username_here
}

Contributing

  1. Fork it ( https://github.com/Krognol/gofycat/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Documentation

Index

Constants

View Source
const (
	// None no action
	None   Action = ""
	Add           = "add_to"
	Move          = "move_contents"
	Remove        = "remove_contents"
)

Variables

View Source
var Album = func(aid string) string { return Albums() + "/" + aid }
View Source
var AlbumDescription = func(aid string) string { return Album(aid) + "/description" }
View Source
var AlbumFolder = func(fid string) string { return AlbumFolders() + "/" + fid }
View Source
var AlbumFolders = func() string { return Me() + "/album-folders" }
View Source
var AlbumNsfw = func(aid string) string { return Album(aid) + "/nsfw" }
View Source
var AlbumOrder = func(aid string) string { return Album(aid) + "/order" }
View Source
var AlbumPublished = func(aid string) string { return Album(aid) + "/published" }
View Source
var AlbumTitle = func(aid string) string { return Album(aid) + "/title" }
View Source
var Albums = func() string { return Me() + "/albums" }
View Source
var Authentication = func() string { return Base() + "oauth/token" }
View Source
var Base = func() string { return "https://api.gfycat.com/v1/" }
View Source
var BookmarkFolder = func(id string) string { return BookmarkFolders() + "/" + id }
View Source
var BookmarkFolderContents = func(fid, gid string) string { return BookmarkFolder(fid) + "/contents/" + gid }
View Source
var BookmarkFolders = func() string { return Me() + "/bookmark-folders" }
View Source
var BookmarkGfy = func(id string) string { return Bookmarks() + "/" + id }
View Source
var Bookmarks = func() string { return Me() + "/bookmarks" }
View Source
var DomainWhitelist = func() string { return Me() + "/domain-whitelist" }
View Source
var Folder = func(folderid string) string { return Folders() + "/" + folderid }
View Source
var FolderName = func(folderid string) string { return Folder(folderid) + "/name" }
View Source
var Folders = func() string { return Me() + "/folders" }
View Source
var Followers = func() string { return Me() + "/followers" }
View Source
var Follows = func() string { return Me() + "/follows" }
View Source
var FollowsCats = func() string { return Follows() + "/gfycats" }
View Source
var FollowsUser = func(user string) string { return Follows() + "/" + user }
View Source
var GeoWhitelist = func() string { return Me() + "/geo-whitelist" }
View Source
var GfycatDescription = func(gid string) string { return _Gfycat(gid) + "/description" }
View Source
var GfycatDomainWhitelist = func(gid string) string { return _Gfycat(gid) + "/domain-whitelist" }
View Source
var GfycatGeoWhitelist = func(gid string) string { return _Gfycat(gid) + "/geo-whitelist" }
View Source
var GfycatNsfw = func(gid string) string { return _Gfycat(gid) + "/nsfw" }
View Source
var GfycatPublished = func(gid string) string { return _Gfycat(gid) + "/published" }
View Source
var GfycatSearch = func(text string) string { return TestApi() + "/gfycats/search?search_text=" + text }
View Source
var GfycatTags = func(gid string) string { return _Gfycat(gid) + "/tags" }
View Source
var GfycatTitle = func(gid string) string { return _Gfycat(gid) + "/title" }
View Source
var Gfycats = func() string { return Base() + "gfycats" }
View Source
var Me = func() string { return Base() + "me" }

======= DON'T USE THESE ENDPOINTS ========

View Source
var MyCats = func() string { return Me() + "/gfycats" }
View Source
var Tags = func() string { return Base() + "tags" }
View Source
var TestApi = func() string { return "https://api.gfycat.com/v1test" }
View Source
var TrendingGfycats = func() string { return Gfycats() + "/trending" }
View Source
var TrendingGfycatsTag = func(tag string) string { return TrendingGfycats() + "?" + tag }
View Source
var TrendingTags = func() string { return Tags() + "/trending" }
View Source
var TrendingTagsPopulated = func() string { return TrendingTags() + "/populated" }
View Source
var UserAlbumLinkTextContents = func(uid, lt string) string { return Users() + uid + "/album_link/" + lt }
View Source
var UserAlbums = func(uid, aid string) string { return Users() + "/" + uid + "/albums/" + aid }
View Source
var UserCats = func(user string) string { return _User(user) + "/gfycats" }
View Source
var UserSearch = func(text string) string { return TestApi() + "/me/gfycats/search?search_text=" + text }
View Source
var Users = func() string { return Base() + "users/" }
View Source
var Verification = func() string { return Me() + "/send_verification_email" }
View Source
var Verified = func() string { return Me() + "/email_verified" }

Functions

This section is empty.

Types

type Action

type Action string

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"`
}

type Cat

type Cat struct {
	ClientID, ClientSecret string
	Type                   GrantType
	// contains filtered or unexported fields
}

func New

func New(clientid, secret string, t GrantType) *Cat

func (*Cat) BookmarkGfy

func (c *Cat) BookmarkGfy(id string) (*http.Response, error)

func (*Cat) BookmarkGfyInFolder

func (c *Cat) BookmarkGfyInFolder(folder, gfy string) (*http.Response, error)

func (*Cat) ChangeFolderName

func (g *Cat) ChangeFolderName(newName, folderid string) (*http.Response, error)

func (*Cat) CheckFollow

func (g *Cat) CheckFollow(user string) (int, error)

func (*Cat) CheckStatusOfUpload

func (c *Cat) CheckStatusOfUpload(name string) (*Status, error)

func (*Cat) CreateAlbum

func (c *Cat) CreateAlbum(name string) (*http.Response, error)

func (*Cat) CreateAlbumInFolder

func (c *Cat) CreateAlbumInFolder(folder, title, description string, contents []string) (*http.Response, error)

func (*Cat) CreateFolder

func (g *Cat) CreateFolder(foldername, insidefolder string) (*http.Response, error)

func (*Cat) DeleteDomainWhitelist

func (g *Cat) DeleteDomainWhitelist() (*http.Response, error)

func (*Cat) DeleteFolder

func (g *Cat) DeleteFolder(folderid string) (*http.Response, error)

func (*Cat) DeleteGeoWhitelist

func (g *Cat) DeleteGeoWhitelist() (*http.Response, error)

func (*Cat) DeleteGfycat

func (c *Cat) DeleteGfycat(gfyid string) (*http.Response, error)

func (*Cat) DeleteGfycatDescription

func (c *Cat) DeleteGfycatDescription(gfyid, desc string) (*http.Response, error)

func (*Cat) DeleteGfycatDomainWhitelist

func (c *Cat) DeleteGfycatDomainWhitelist(gfyid string) (*http.Response, error)

func (*Cat) DeleteGfycatGeoWhitelist

func (c *Cat) DeleteGfycatGeoWhitelist(gfyid string) (*http.Response, error)

func (*Cat) DeleteGfycatTitle

func (c *Cat) DeleteGfycatTitle(gfyid string) (*http.Response, error)

func (*Cat) EmailIsVerified

func (g *Cat) EmailIsVerified() (bool, error)

func (*Cat) FollowUser

func (g *Cat) FollowUser(user string) (int, error)

func (*Cat) GetAlbumContents

func (c *Cat) GetAlbumContents(album string) (*http.Response, error)

func (*Cat) GetAlbumFolders

func (c *Cat) GetAlbumFolders() (*http.Response, error)

func (*Cat) GetBookmarkFolderContent

func (c *Cat) GetBookmarkFolderContent(folderid string) (*http.Response, error)

func (*Cat) GetBookmarks

func (c *Cat) GetBookmarks() (*http.Response, error)

func (*Cat) GetDomainWhitelist

func (g *Cat) GetDomainWhitelist() (*http.Response, error)

func (*Cat) GetFolder

func (g *Cat) GetFolder(folderid string) (*http.Response, error)

func (*Cat) GetFolderName

func (g *Cat) GetFolderName(folderid string) (*http.Response, error)

func (*Cat) GetFollows

func (g *Cat) GetFollows() (*http.Response, error)

func (*Cat) GetGeoWhitelist

func (g *Cat) GetGeoWhitelist() (*http.Response, error)

func (*Cat) GetGfycatDomainWhitelist

func (c *Cat) GetGfycatDomainWhitelist(gfyid string) (*http.Response, error)

func (*Cat) GetGfycatGeoWhitelist

func (c *Cat) GetGfycatGeoWhitelist(gfyid string) (*http.Response, error)

func (*Cat) GetListOfFollowers

func (g *Cat) GetListOfFollowers() (*http.Response, error)

func (*Cat) GetPrivateFeed

func (g *Cat) GetPrivateFeed() (*UserFeed, error)

func (*Cat) GetSelfDetails

func (g *Cat) GetSelfDetails() (*User, error)

func (*Cat) GetTimeline

func (g *Cat) GetTimeline() (*UserFeed, error)

func (*Cat) GetToken

func (g *Cat) GetToken() string

func (*Cat) GetTrendingGfycats

func (c *Cat) GetTrendingGfycats(tag, cursor string) ([]Gfycat, error)

Count is 10 by default

func (*Cat) GetTrendingTags

func (c *Cat) GetTrendingTags() ([]string, error)

func (*Cat) GetTrendingTagsPopulated

func (c *Cat) GetTrendingTagsPopulated(values url.Values) ([]Gfycat, error)

func (*Cat) GetUser

func (g *Cat) GetUser(userid string) (*User, error)

func (*Cat) GetUserAlbumContents

func (c *Cat) GetUserAlbumContents(user, album string) (*http.Response, error)

TODO: Check following two functions

func (*Cat) GetUserAlbumContentsByLinkText

func (c *Cat) GetUserAlbumContentsByLinkText(user, linkText string) (*http.Response, error)

jesus

func (*Cat) GetUserFeed

func (g *Cat) GetUserFeed(user string) (*UserFeed, error)

func (*Cat) GetUsername

func (g *Cat) GetUsername(username string) (string, error)

func (*Cat) GfyIsBookmarked

func (c *Cat) GfyIsBookmarked(gfy string) (*http.Response, error)

func (*Cat) MoveAlbumToFolder

func (c *Cat) MoveAlbumToFolder(parentid, album string) (*http.Response, error)

func (*Cat) MoveContentInFolder

func (g *Cat) MoveContentInFolder(folderid, parentid string, gfyids []string) (*http.Response, error)

func (*Cat) MoveFolder

func (g *Cat) MoveFolder(folderid, parentid string) (*http.Response, error)

func (*Cat) MoveToFolder

func (c *Cat) MoveToFolder(folder, parent string, gfys []string) (*http.Response, error)

func (*Cat) MyFolders

func (g *Cat) MyFolders() (*http.Response, error)

func (*Cat) PutAlbumDescription

func (c *Cat) PutAlbumDescription(album, value string) (*http.Response, error)

func (*Cat) PutAlbumNsfw

func (c *Cat) PutAlbumNsfw(value int, album string) (*http.Response, error)

func (*Cat) PutAlbumTitle

func (c *Cat) PutAlbumTitle(album, value string) (*http.Response, error)

func (*Cat) PutPublished

func (c *Cat) PutPublished(value int, album string) (*http.Response, error)

func (*Cat) ResetPassword

func (g *Cat) ResetPassword(usernameOrEmail string) (success bool, err error)

func (*Cat) SearchGfycats

func (c *Cat) SearchGfycats(searchText string) (*GfycatSearchT, error)

func (*Cat) SearchUserAccount

func (c *Cat) SearchUserAccount(searchText string) ([]Gfycat, error)

func (*Cat) SendVerificationEmail

func (g *Cat) SendVerificationEmail() (success bool, err error)

func (*Cat) UnbookmarkGfy

func (c *Cat) UnbookmarkGfy(gfy string) (*http.Response, error)

func (*Cat) UnbookmarkGfyInFolder

func (c *Cat) UnbookmarkGfyInFolder(folder, gfy string) (*http.Response, error)

func (*Cat) UnfollowUser

func (g *Cat) UnfollowUser(user string) (int, error)

func (*Cat) UpdateAlbum

func (c *Cat) UpdateAlbum(action Action, album, parentid string, a ...string) (*http.Response, error)

func (*Cat) UpdateDetails

func (g *Cat) UpdateDetails(u *Update) (success bool, err error)

func (*Cat) UpdateDomainWhitelist

func (g *Cat) UpdateDomainWhitelist(domains []string) error

func (*Cat) UpdateGeoWhitelist

func (g *Cat) UpdateGeoWhitelist(geolocations []string) error

func (*Cat) UpdateGfycatDescription

func (c *Cat) UpdateGfycatDescription(gfyid, desc string) (*http.Response, error)

func (*Cat) UpdateGfycatDomainWhitelist

func (c *Cat) UpdateGfycatDomainWhitelist(gfyid string, domains []string) (*http.Response, error)

func (*Cat) UpdateGfycatGeoWhitelist

func (c *Cat) UpdateGfycatGeoWhitelist(gfyid string, geoLocations []string) (*http.Response, error)

func (*Cat) UpdateGfycatNsfw

func (c *Cat) UpdateGfycatNsfw(gfyid, nsfw string) (*http.Response, error)

func (*Cat) UpdateGfycatPublished

func (c *Cat) UpdateGfycatPublished(gfyid, pub string) (*http.Response, error)

func (*Cat) UpdateGfycatTags

func (c *Cat) UpdateGfycatTags(gfyid string, tags []string) (*http.Response, error)

func (*Cat) UpdateGfycatTitle

func (c *Cat) UpdateGfycatTitle(gfyid, title string) (*http.Response, error)

func (*Cat) UploadFile

func (c *Cat) UploadFile(file *UploadFile) (*http.Response, error)

type Crop

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

type Cut

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

type Gfycat

type Gfycat struct {
	GfyID             string `json:"gfyId"`
	GfyName           string `json:"gfyName"`
	GfyNumber         string `json:"gfyNumber"`
	WebmURL           string `json:"webmUrl"`
	GifURL            string `json:"gifUrl"`
	MobileURL         string `json:"mobileUrl"`
	MobilePosterURL   string `json:"mobilePosterUrl"`
	MiniURL           string `json:"miniUrl"`
	MiniPosterURL     string `json:"miniPosterUrl"`
	PosterURL         string `json:"posterUrl"`
	Thumb360URL       string `json:"thumb360Url"`
	Thumb360PosterURL string `json:"thumb360PosterUrl"`
	Thumb100PosterURL string `json:"thumb100PosterUrl"`
	Max5MBGif         string `json:"max5mbGif"`
	Max2MBGif         string `json:"max2mbGif"`
	MJPGURL           string `json:"mjpgUrl"`
	Width             int    `json:"width"`
	Height            int    `json:"height"`
	AvgColor          string `json:"avgColor"`
	FrameRate         int    `json:"frameRate"`
	NumFrames         int    `json:"numFrames"`
	MP4Size           int    `json:"mp4Size"`
	WebmSize          int    `json:"webmSize"`
	GifSize           int    `json:"gifSize"`
	Source            int    `json:"source"`
	CreateDate        int    `json:"createDate"`
	NSFW              string `json:"nsfw"`
	MP4URL            string `json:"mp4Url"`
	//Likes int `json:"likes"`
	//Published int `json:"published"`
	Dislikes           int         `json:"dislikes"`
	ExtraLemmas        string      `json:"extraLemmas"`
	MD5                string      `json:"md5"`
	Views              int         `json:"views"`
	Tags               []string    `json:"tags"`
	Username           string      `json:"userName"`
	Title              string      `json:"title"`
	Description        string      `json:"description"`
	LanguageCategories interface{} `json:"languageCategories"`
	DomainWhiteList    []string    `json:"domainWhitelist"`
}

Gfycat object

type GfycatSearchT

type GfycatSearchT struct {
	Gfycats []Gfycat `json:"gfycats"`
	Found   int      `json:"found"`
	Cursor  string   `json:"cursor"`
}

type GrantType

type GrantType int
const (
	ILLEGAL GrantType = iota
	Client
	Password
)

type Operation

type Operation struct {
	Op        string   `json:"op"`
	Path      string   `json:"path"`
	Value     string   `json:"value"`
	Whitelist []string `json:"value,-"`
}

type Status

type Status struct {

	// While encoding or not found
	Task string `json:"task"`
	Time int    `json:"time"`

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

type Update

type Update struct {
	Operations []*Operation `json:"operations"`
}

type UploadFile

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

type UploadRequest

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

type User

type User struct {
	Userid                    string `json:"userid"`
	Username                  string `json:"username"`
	Email                     string `json:"email"`
	Description               string `json:"description"`
	ProfileURL                string `json:"profileUrl"`
	Name                      string `json:"name"`
	Views                     string `json:"views"`
	UploadNotices             bool   `json:"uploadNotices"`
	EmailVerified             bool   `json:"emailVerified"`
	URL                       string `json:"url"`
	CreateDate                string `json:"createDate"`
	ProfileImageURL           string `json:"profileImageUrl"`
	Verified                  bool   `json:"verified"`
	Followers                 string `json:"followers"`
	Following                 string `json:"following"`
	GeoWhitelist              string `json:"geoWhitelist"`
	DomainWhitelist           string `json:"domainWhitelist"`
	IFrameProfileImageVisible bool   `json:"iframeProfileImageVisible"`
	PublishedGfycats          string `json:"publishedGfycats"`
	PublishedAlbums           string `json:"publishedAlbums"`
}

type UserFeed

type UserFeed struct {
	Cursor  string   `json:"cursor"`
	Gfycats []Gfycat `json:"contents"`
}

Jump to

Keyboard shortcuts

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