gonnachan

package module
v0.0.0-...-65710b7 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2020 License: MIT Imports: 8 Imported by: 0

README

Gonnachan

Go Report Card

Konachan api written in go WORK IN PROGRESS

Supported Servers

http://konachan.com/
https://yande.re/
https://gelbooru.com/
https://safebooru.org/
https://rule34.xxx/

WIP Servers

https://sankakucomplex.com

Usage

Imports

import "github.com/insomnyawolf/Gonnachan"

Code

	Req := gonnachan.GonachanPostRequest{}

PostRequest:

type PostRequest struct {
	Tags       []string
	BeforeID   int64
	AfterID    int64
	RandOrder  bool
	Rating     string
	Height     int
	Width      int
	MaxResults int
	TargetAPI  string
	serverType int
	url        string
}

Methods:

	//Results Execute and process query.
	//Returns PostResult Struct with all the data needed
	res := Req.GetResults()

	//If you wanna see what is the api query beeing made
	//you can use the method APIrequest(), it will return a string
	Req.APIrequest()

PostResult:

type PostResult struct {
	ID       int64  `json:"id"`
	Tags     string `json:"tags"`
	Author   string `json:"author"`
	Source   string `json:"source"`
	Score    int64  `json:"score"`
	Md5      string `json:"md5"`
	FileSize int64  `json:"file_size"`
	FileURL  string `json:"file_url"`
	Rating   string `json:"rating"`
	Width    int64  `json:"width"`
	Height   int64  `json:"height"`
	PostURL  string
}

Documentation

Index

Constants

View Source
const (
	//ServerKonachan Host
	ServerKonachan = "https://konachan.com/"
	//ServerYandere Host
	ServerYandere = "https://yande.re/"
	//ServerGelbooru Host
	ServerGelbooru = "https://gelbooru.com/"
	//ServerRule34 Host
	ServerRule34 = "https://rule34.xxx/"
	//ServerSafebooru Host
	ServerSafebooru = "https://safebooru.org/"
	//ServerTBIB Host
	ServerTBIB = "https://tbib.org/"
	//ServerSankaku Host
	ServerSankaku = "https://capi-beta.sankakucomplex.com/"
)
View Source
const (

	//RatingSafe PG
	RatingSafe = "safe"
	//RatingQuestionablePG +16 Not supported by every server
	RatingQuestionablePG = "questionableless"
	//RatingQuestionable +16
	RatingQuestionable = "questionable"
	//RatingQuestionableExplicit +16 && +18 Not supported by every server
	RatingQuestionableExplicit = "questionableplus"
	//RatingExplicit +18
	RatingExplicit = "explicit"
)
View Source
const (
	//ErrNoResults No results found
	ErrNoResults = 1
	//ErrEmpty No answer from server
	ErrEmpty = 2
)

Variables

This section is empty.

Functions

This section is empty.

Types

type PostRequest

type PostRequest struct {
	Tags         []string
	ExcludedTags []string
	BeforeID     int64
	AfterID      int64
	RandOrder    bool
	Rating       string
	Height       int
	Width        int
	MaxResults   int
	TargetAPI    string
	// contains filtered or unexported fields
}

PostRequest store data prepare the api querry

func (*PostRequest) APIrequest

func (c *PostRequest) APIrequest() string

APIrequest parse PostRequest to get the equivalent api query url

func (*PostRequest) GetResults

func (c *PostRequest) GetResults() ([]PostResult, error)

GetResults runs the query obtained at APIrequest and returns PostResult

type PostResult

type PostResult struct {
	ID       int64  `json:"id"`
	Tags     string `json:"tags"`
	Author   string `json:"author"`
	Source   string `json:"source"`
	Score    int64  `json:"score"`
	Md5      string `json:"md5"`
	FileSize int64  `json:"file_size"`
	FileURL  string `json:"file_url"`
	Rating   string `json:"rating"`
	Width    int64  `json:"width"`
	Height   int64  `json:"height"`
	PostURL  string
}

PostResult has useful data obtained from the API

func (*PostResult) RatingString

func (c *PostResult) RatingString() string

RatingString Returns the human-readable sting for rating values

Jump to

Keyboard shortcuts

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