getmoe

package module
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2020 License: MIT Imports: 13 Imported by: 2

README

Get Moe

GoDoc Build Status codecov Go Report Card Dependabot Status

Get Moe is 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). This project started for the purpose of researching of various characters popularity, rather than image grabbing, however save feature is also available.

Installing

macOS

brew install leonidboykov/tap/getmoe

Windows

scoop bucket add getmoe https://github.com/leonidboykov/scoop-bucket.git
scoop install getmoe

Development version

go get -u github.com/leonidboykov/cmd/getmoe

Development documentation is available on GoDoc.

Usage

The only implemented command for now is get. Here is the usage example

USAGE:
   getmoe [global options] command [command options] [arguments...]

COMMANDS:
     get      get data from booru
     help, h  Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --quiet, -q    disable progress bar
   --help, -h     show help
   --version, -v  print the version

Login and password are optional.

Supported Boards

  • yande.re
  • konachan.com
  • gelbooru.com
  • danbooru.donmai.us
  • chan.sankakucomplex.com
  • idol.sankakucomplex.com

Custom boorus are not available yet.

License

getmoe is a free software licensed under the MIT license.

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

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterProvider added in v0.5.0

func RegisterProvider(name string, provider Provider)

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

func NewBoardWithProvider(provider Provider) *Board

NewBoardWithProvider creates a new board with provided configuration.

func (*Board) Request

func (b *Board) Request() ([]Post, error)

Request gets images by tags.

func (*Board) RequestAll

func (b *Board) RequestAll() ([]Post, error)

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

type JSONTime struct {
	time.Time
}

JSONTime provides unmarshaller for json timestamp.

Example:

"created_at": {
    "json_class": "Time",
    "s": 1552231391,
    "n": 0
}

func (*JSONTime) UnmarshalJSON added in v0.5.0

func (t *JSONTime) UnmarshalJSON(data []byte) error

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

func (*Post) HasTag

func (p *Post) HasTag(tag string) bool

HasTag returns true if post has specified tag

func (*Post) Save

func (p *Post) Save(saveDir string) error

Save post to dir

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 Rating

type Rating string

Rating defines boorus rating system

const (
	RatingSafe         Rating = "s"
	RatingQuestionable Rating = "q"
	RatingExplicit     Rating = "e"
)

Boorus rating system has safe, questionable and explicit tags.

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

func NewTags(tags ...string) *Tags

NewTags allocates a new list. You may provide as many tags as you want.

t := getmoe.NewTags("tag1", "tag2")

func (*Tags) AfterDate

func (t *Tags) AfterDate(date time.Time) *Tags

AfterDate appends date tag with after prefix.

func (*Tags) And

func (t *Tags) And(tags ...string) *Tags

And appends tags to tag list.

t.And("tag3", "tag4")

func (*Tags) AtDate

func (t *Tags) AtDate(date time.Time) *Tags

AtDate appends date tag.

func (*Tags) BeforeDate

func (t *Tags) BeforeDate(date time.Time) *Tags

BeforeDate appends date tag with before prefix.

func (*Tags) No

func (t *Tags) No(tags ...string) *Tags

No appends tags with 'no' prefix to tag list.

func (*Tags) Or

func (t *Tags) Or(tags ...string) *Tags

Or appends tags with 'or' prefix to tag list. t.Or("tag5", "tag6")

func (Tags) String

func (t Tags) String() string

func (*Tags) WithRating

func (t *Tags) WithRating(r ...Rating) *Tags

WithRating appends rating tags.

func (*Tags) WithoutRating

func (t *Tags) WithoutRating(r ...Rating) *Tags

WithoutRating appends rating tags with 'no' prefix.

type URLString

type URLString struct {
	url.URL
}

URLString provides a helper to parse string as url.URL

func (*URLString) UnmarshalYAML

func (f *URLString) UnmarshalYAML(unmashal func(interface{}) error) error

UnmarshalYAML implements unmarshaller interface for YAML

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.

Jump to

Keyboard shortcuts

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