Documentation
¶
Overview ¶
Package getmoe provides a REST client for image boards, such as Moebooru, Gelbooru and Danbooru. The goal of the project is to provide APIs for the most well-known image boards (boorus).
Index ¶
- func RegisterProvider(name string, provider Provider)
- type AuthConfiguration
- type Board
- type BoardConfiguration
- type DownloadConfiguration
- type GlobalConfiguration
- type JSONTime
- type Post
- type Provider
- type ProviderConfiguration
- type Rating
- type RequestConfiguration
- type Tags
- func (t *Tags) AfterDate(date time.Time) *Tags
- func (t *Tags) And(tags ...string) *Tags
- func (t *Tags) AtDate(date time.Time) *Tags
- func (t *Tags) BeforeDate(date time.Time) *Tags
- func (t *Tags) No(tags ...string) *Tags
- func (t *Tags) Or(tags ...string) *Tags
- func (t Tags) String() string
- func (t *Tags) WithRating(r ...Rating) *Tags
- func (t *Tags) WithoutRating(r ...Rating) *Tags
- type URLString
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterProvider ¶ added in v0.5.0
RegisterProvider registers booru provider
Types ¶
type AuthConfiguration ¶
type AuthConfiguration struct { Login string `yaml:"login"` Password string `yaml:"password"` HashedPassword string `yaml:"hashed_password"` APIKey string `yaml:"api_key"` }
AuthConfiguration provides configuration for authenticating.
type Board ¶
type Board struct { Provider Provider // contains filtered or unexported fields }
Board holds data for API access.
func NewBoard ¶
func NewBoard(providerName string, config BoardConfiguration) (*Board, error)
NewBoard creates a new board with provided configuration.
func NewBoardWithProvider ¶ added in v0.5.0
NewBoardWithProvider creates a new board with provided configuration.
func (*Board) RequestAll ¶
RequestAll checks all pages.
type BoardConfiguration ¶
type BoardConfiguration struct {
Provider ProviderConfiguration `yaml:",inline"`
}
BoardConfiguration holds board related configuration.
type DownloadConfiguration ¶
type DownloadConfiguration struct {
Request RequestConfiguration `yaml:",inline"`
}
DownloadConfiguration holds download related configuration.
type GlobalConfiguration ¶
type GlobalConfiguration struct { Boards map[string]BoardConfiguration `yaml:"boards"` Download DownloadConfiguration `yaml:"download"` }
GlobalConfiguration provides global configuration.
func Load ¶
func Load(filename string) (*GlobalConfiguration, error)
Load loads global configuration.
type JSONTime ¶ added in v0.5.0
JSONTime provides unmarshaller for json timestamp.
Example:
"created_at": { "json_class": "Time", "s": 1552231391, "n": 0 }
func (*JSONTime) UnmarshalJSON ¶ added in v0.5.0
UnmarshalJSON marshals JSONTime to time.Time.
type Post ¶
type Post struct { ID int `json:"id"` Width int `json:"width"` Height int `json:"height"` FileURL string `json:"file_url"` FileType string `json:"file_type"` FileSize int `json:"file_size"` CreatedAt time.Time `json:"created_at"` Tags []string `json:"tags"` Author string `json:"author"` Source string `json:"source"` Rating string `json:"rating"` Hash string `json:"hash"` Score int `json:"score"` VoteCount int `json:"vote_count"` FavCount int `json:"fav_count"` }
Post contains post data, represents intersection of *boorus post structs
type Provider ¶
type Provider interface { New(ProviderConfiguration) Auth(AuthConfiguration) BuildRequest(RequestConfiguration) NextPage() PageRequest() (*http.Request, error) Parse([]byte) ([]Post, error) }
Provider describes Board provider
func NewProvider ¶ added in v0.5.0
func NewProvider(providerName string, conf ProviderConfiguration) (*Provider, error)
NewProvider creates a new provider
type ProviderConfiguration ¶
type ProviderConfiguration struct { Name string `yaml:"provider"` URL URLString `yaml:"url"` Auth AuthConfiguration `yaml:",inline"` PasswordSalt string `yaml:"password_salt"` AppkeySalt string `yaml:"appkey_salt"` PostsLimit int `yaml:"posts_limit"` }
ProviderConfiguration holds provider related configuration.
type RequestConfiguration ¶
type RequestConfiguration struct {
Tags Tags `yaml:"tags"`
}
RequestConfiguration holds request related configuration.
type Tags ¶
type Tags []string
Tags provides fluent-style builder for boorus tags.
Example ¶
package main import ( "fmt" "github.com/leonidboykov/getmoe" ) func main() { t := getmoe.NewTags("first_tag", "second_tag") t.And("and_this_tag") t.No("except_this_tag") t.WithoutRating(getmoe.RatingQuestionable, getmoe.RatingExplicit) fmt.Println(t) }
Output: first_tag second_tag and_this_tag -except_this_tag -rating:q -rating:e
func NewTags ¶
NewTags allocates a new list. You may provide as many tags as you want.
t := getmoe.NewTags("tag1", "tag2")
func (*Tags) BeforeDate ¶
BeforeDate appends date tag with before prefix.
func (*Tags) WithRating ¶
WithRating appends rating tags.
func (*Tags) WithoutRating ¶
WithoutRating appends rating tags with 'no' prefix.
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
cmd
|
|
internal
|
|
danbooru
Package danbooru implements a simple library for accessing Danbooru-based image boards.
|
Package danbooru implements a simple library for accessing Danbooru-based image boards. |
gelbooru
Package gelbooru implements a simple library for accessing Gelbooru-based image boards.
|
Package gelbooru implements a simple library for accessing Gelbooru-based image boards. |
moebooru
Package moebooru implements a simple library for accessing Moebooru-based image boards.
|
Package moebooru implements a simple library for accessing Moebooru-based image boards. |
sankaku
Package sankaku implements a simple library for accessing Sankakucomplex-based image boards.
|
Package sankaku implements a simple library for accessing Sankakucomplex-based image boards. |