e621

package
v0.0.0-...-3c50eb6 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2019 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NO_PARENT   int = -1
	NO_CHILDREN int = -1
)
View Source
const (
	Safe         Rating = "s"
	Questionable        = "q"
	Explicit            = "e"
)
View Source
const (
	JPG  FileExt = "jpg"
	PNG          = "png"
	GIF          = "gif"
	SWF          = "swf"
	WEBM         = "webm"
)
View Source
const (
	NO_POST int = -1
)
View Source
const (
	TestFileGetPost = "testdata/getpost.json"
)

Variables

This section is empty.

Functions

func NewMockServer

func NewMockServer() (*http.ServeMux, *url.URL)

Types

type CheckMD5

type CheckMD5 struct {
	Md5    string `json:"md5"`
	Exists bool   `json:"exists"`
	PostID int    `json:"post_id"` // This field is valied only if the post exists.
}

type Client

type Client struct {
	BaseURL    *url.URL
	HTTPClient *http.Client
	UserName   string
	Logger     *log.Logger
}

func NewClient

func NewClient(baseURL, userName string, logger *log.Logger) (*Client, error)

func NewTestClient

func NewTestClient(testServerURL *url.URL) *Client

func (*Client) CheckMD5

func (c *Client) CheckMD5(ctx context.Context, md5 string) (*CheckMD5, error)

func (*Client) GetPostByID

func (c *Client) GetPostByID(ctx context.Context, id uint) (*Post, error)

post/show

func (*Client) GetPostByMD5

func (c *Client) GetPostByMD5(ctx context.Context, md5 string) (*Post, error)

func (*Client) List

func (c *Client) List(ctx context.Context, p ListParams) (*[]Post, error)

func (*Client) ListWithTypedTags

func (c *Client) ListWithTypedTags(ctx context.Context, p ListParams) (*[]TypedTagsPost, error)

func (*Client) NewRequest

func (client *Client) NewRequest(ctx context.Context, subURL string, query map[string]string, method string, body io.Reader) (*http.Request, error)

func (*Client) Popular

func (c *Client) Popular(ctx context.Context, interval string) (*[]Post, error)

func (*Client) PostTagHistory

func (c *Client) PostTagHistory(ctx context.Context, p PostTagHistoryParams) (*[]PostTagHistory, error)

type CreatedAt

type CreatedAt struct {
	JSONClass string `json:"json_class"`
	S         int    `json:"s"`
	N         int    `json:"n"`
}

type FileExt

type FileExt string

func (FileExt) String

func (f FileExt) String() string

type ListParams

type ListParams struct {
	Limit    int
	BeforeId int
	Page     int
	Tags     string
}

type Post

type Post struct {
	ID               int    `json:"id"`
	TagsString       string `json:"tags"`
	LockedTagsString string `json:"locked_tags"`
	Tags             []string
	LockedTags       []string
	Description      string    `json:"description"`
	CreatedAt        CreatedAt `json:"created_at"`
	CreatorID        int       `json:"creator_id"`
	Author           string    `json:"author"`
	Change           int       `json:"change"`
	Source           string    `json:"source"`
	Score            int       `json:"score"`
	FavCount         int       `json:"fav_count"`
	Md5              string    `json:"md5"`
	FileSize         int       `json:"file_size"`
	FileURL          string    `json:"file_url"`
	FileExt          FileExt   `json:"file_ext"`
	PreviewURL       string    `json:"preview_url"`
	PreviewWidth     int       `json:"preview_width"`
	PreviewHeight    int       `json:"preview_height"`
	SampleURL        string    `json:"sample_url"`
	SampleWidth      int       `json:"sample_width"`
	SampleHeight     int       `json:"sample_height"`
	Rating           Rating    `json:"rating"`
	Status           Status    `json:"status"`
	Width            int       `json:"width"`
	Height           int       `json:"height"`
	HasComments      bool      `json:"has_comments"`
	HasNotes         bool      `json:"has_notes"`
	HasChildren      bool      `json:"has_children"`
	ChildrenPtr      string    `json:"children"`  //null or id
	ParentIDPtr      string    `json:"parent_id"` //null or id
	Children         int
	ParentID         int
	Artist           []string `json:"artist"`
	Sources          []string `json:"sources"`
	Delreason        string   `json:"delreason"`
}

Note: the following fields are not available for deleted posts: source, sources, md5, file_size, file_ext, preview_width, preview_height, sample_url, sample_width, sample_height, has_children, children

type PostTagHistory

type PostTagHistory struct {
	ID         int    `json:"id"`
	PostID     int    `json:"post_id"`
	CreatedAt  int    `json:"created_at"`
	TagsString string `json:"tags"`
	Tags       []string
	Source     string `json:"source"`
}

type PostTagHistoryParams

type PostTagHistoryParams struct {
	PostId      uint
	DateStart   string
	DateEnd     string
	UserId      uint
	UserName    string
	Source      string
	Tags        string
	Reason      string
	Description string
	Before      string
	After       string
}

type Rating

type Rating string

func (Rating) String

func (r Rating) String() string

type Status

type Status int
const (
	Active Status = iota
	Flagged
	Pending
	Deleted
)

func (Status) String

func (s Status) String() string

type TypedTags

type TypedTags struct {
	General   []string `json:"general"`
	Artist    []string `json:"artist"`
	CopyRight []string `json:"copyright"`
	Character []string `json:"character"`
	Species   []string `json:"species"`
}

type TypedTagsPost

type TypedTagsPost struct {
	ID               int       `json:"id"`
	LockedTagsString string    `json:"locked_tags"`
	Tags             TypedTags `json:"tags"`
	LockedTags       []string
	Description      string    `json:"description"`
	CreatedAt        CreatedAt `json:"created_at"`
	CreatorID        int       `json:"creator_id"`
	Author           string    `json:"author"`
	Change           int       `json:"change"`
	Source           string    `json:"source"`
	Score            int       `json:"score"`
	FavCount         int       `json:"fav_count"`
	Md5              string    `json:"md5"`
	FileSize         int       `json:"file_size"`
	FileURL          string    `json:"file_url"`
	FileExt          FileExt   `json:"file_ext"`
	PreviewURL       string    `json:"preview_url"`
	PreviewWidth     int       `json:"preview_width"`
	PreviewHeight    int       `json:"preview_height"`
	SampleURL        string    `json:"sample_url"`
	SampleWidth      int       `json:"sample_width"`
	SampleHeight     int       `json:"sample_height"`
	Rating           Rating    `json:"rating"`
	Status           Status    `json:"status"`
	Width            int       `json:"width"`
	Height           int       `json:"height"`
	HasComments      bool      `json:"has_comments"`
	HasNotes         bool      `json:"has_notes"`
	HasChildren      bool      `json:"has_children"`
	ChildrenPtr      string    `json:"children"`  //null or id
	ParentIDPtr      string    `json:"parent_id"` //null or id
	Children         int
	ParentID         int
	Artist           []string `json:"artist"`
	Sources          []string `json:"sources"`
	Delreason        string   `json:"delreason"`
}

Jump to

Keyboard shortcuts

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