api

package
v0.1.15 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2021 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client added in v0.1.8

type Client struct {
	BaseURL string
	Client  *http.Client
	Artist  bool
	Limit   chan struct{}
}

Client is used to store common api information for http requests

func NewClient added in v0.1.6

func NewClient(args ...interface{}) (client Client)

NewClient will generate a basic api client for use. Valid optional args are: Int: set the limit for goroutines, bool: Flag artist in use for PrettyNames

func (*Client) NewDoujin added in v0.1.8

func (a *Client) NewDoujin(nnn int) Doujin

NewDoujin is used to generate a doujin instance with Image instances attached at APIImages

func (*Client) NewSearch added in v0.1.8

func (a *Client) NewSearch(s *SearchOpts) Search

NewSearch will return a Search struct from the qurey and page information

type Doujin

type Doujin struct {
	ID       json.Number `json:"id"`
	MediaID  string      `json:"media_id"`
	NumPages int         `json:"num_pages"`
	Images   struct {
		Cover     image   `json:"cover"`
		Thumbnail image   `json:"thumbnail"`
		Pages     []image `json:"pages"`
	} `json:"images"`
	Titles struct {
		English  string `json:"english"`
		Japanese string `json:"japanese"`
		Pretty   string `json:"pretty"`
	} `json:"title"`
	Tags []struct {
		ID   json.Number `json:"id"`
		Type string      `json:"type"`
		Name string      `json:"name"`
	} `json:"tags"`
	APIImages []Image
	Client    *Client
}

Doujin a quick struct for unpacking the response from the nhentai API. Used for responses from nhentai.net/api/galleries/:magicNumber

func (*Doujin) Artist added in v0.1.3

func (d *Doujin) Artist() string

Artist will walk tags to discover the first artist tag for the doujin

func (Doujin) DownloadZip

func (d Doujin) DownloadZip()

DownloadZip is used to pull the Doujin to disk as {doujin.Title.English}.cbz

type Image

type Image struct {
	MediaID  string
	Index    int
	Type     imageType
	Filename string
	URL      string
}

Image is a quick build for generating a URL and filename from the nhentai api resonse.

type Search struct {
	Result []Doujin `json:"result"`
	Pages  int      `json:"num_pages"`
	Client *Client
}

Search is a base struct for search results from the api

func (Search) RenderTable

func (s Search) RenderTable(pretty bool, page int)

RenderTable will provide a pretty view of the search results

func (Search) ReturnDoujin

func (s Search) ReturnDoujin(index int) Doujin

ReturnDoujin will take an index number and return a doujin from the indexed search `Result`

type SearchOpts added in v0.1.11

type SearchOpts struct {
	Search string
	Page   int
	Sort   string
}

SearchOpts is intended to provide a common basing for expanding the options allowed for search in the future

Jump to

Keyboard shortcuts

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