mangarock

package module
v0.0.0-...-bff30a4 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// APIURL is the mangarock api url
	APIURL = "https://api.mangarockhd.com/query/web401"

	// APIMETAURL is mangarock's meta url
	APIMETAURL = "https://api.mangarockhd.com/meta"
)

Variables

This section is empty.

Functions

func ConvertMRItoPNG

func ConvertMRItoPNG(path string) error

ConvertMRItoPNG converts .mri files to .png files

func Decode

func Decode(r io.Reader) (image.Image, error)

Decode reads a MRI image from r and returns it as an image.Image.

func DecodeConfig

func DecodeConfig(r io.Reader) (image.Config, error)

DecodeConfig returns the color model and dimensions of a MRI. To recreate the original header it has to read the whole stream.

func DecodeRaw

func DecodeRaw(r io.Reader) (io.Reader, int, error)

DecodeRaw reads a MRI image from r, returns its original format (WEBP) as an io.Reader and its size in bytes. Can be used if there is no need for an image.Image.

func NormalizeOneDigitNumber

func NormalizeOneDigitNumber(order int) string

NormalizeOneDigitNumber inserts '0' in front of one digit numbers [0-9].

func SaveChapter

func SaveChapter(chapter *Chapter, path string) error

SaveChapter saves given chapter slice

func WithOptions

func WithOptions(options map[string]string) func(*Client)

WithOptions allow creating client with additional options. IE: country

Types

type Author

type Author struct {
	ID        string `json:"oid"`
	Name      string `json:"name"`
	Thumbnail string `json:"thumbnail"`

	// Only available if requested through a manga
	Role string `json:"role"`
}

Author of a manga.

type Category

type Category struct {
	ID   string `json:"oid"`
	Name string `json:"name"`
}

Category of a manga.

type Chapter

type Chapter struct {
	ID   string `json:"oid"`
	Name string `json:"name"`

	// Fields only available if requested as a single object
	Order int `json:"order"`

	// Fields available if requested as chapter
	Pages []string `json:"pages"`
}

Chapter of a manga.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is the mangarock client

func New

func New(options ...func(*Client)) *Client

New returns a brand new mangarock client

func (*Client) Author

func (c *Client) Author(id string) (Author, []Manga, error)

Author returns an author and their mangas.

func (*Client) Chapter

func (c *Client) Chapter(id, cid string) (Chapter, error)

Chapter returns a chapter containing its images.

func (*Client) Latest

func (c *Client) Latest(page int) ([]Manga, error)

Latest returns the latest mangas. It only uses the manga IDs and requests a list like the one that would be returned by a search. Fields like recently added chapters are missing, but authors are added.

func (*Client) Manga

func (c *Client) Manga(id string) (SingleManga, error)

Manga returns a single manga. It may contain more fields than a regular one.

func (*Client) Mangas

func (c *Client) Mangas(ids []string) ([]Manga, error)

Mangas returns a slice of mangas.

func (*Client) Search

func (c *Client) Search(query string) ([]string, error)

Search searches the given query

type Manga

type Manga struct {
	ID              string    `json:"oid"`
	Name            string    `json:"name"`
	Author          Author    `json:"-"`
	Authors         []Author  `json:"authors"`
	AuthorIDs       []string  `json:"author_ids"`
	Genres          []string  `json:"genres"`
	Rank            int       `json:"rank"`
	UpdatedChapters int       `json:"updated_chapters"`
	NewChapters     []Chapter `json:"new_chapters"`
	Completed       bool      `json:"cmpleted"`
	Thumbnail       string    `json:"thumbnail"`
	Updated         time.Time `json:"updated_at"`
}

Manga contains a manga. This struct is returned by endpoints listing mangas.

type Response

type Response struct {
	Code int             `json:"code"`
	Data json.RawMessage `json:"data"`
}

Response is the response of the mangarock web api

type SingleManga

type SingleManga struct {
	Manga
	Description string     `json:"description"`
	Chapters    []Chapter  `json:"chapters"`
	Categories  []Category `json:"rich_categories"`
	Cover       string     `json:"cover"`
	Artworks    []string   `json:"artworks"`
	Aliases     []string   `json:"alias"`
}

SingleManga contains a manga with additional fields. This struct is returned by requests for a single manga.

Jump to

Keyboard shortcuts

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