mangarock

package module
v0.0.0-...-66f06a8 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2019 License: MIT Imports: 6 Imported by: 0

README

MangaRock

GoDoc Go Report Card

A Go client for the MangaRock API. Use mri to decode images.

func main() {
  c := mangarock.New()
  m, err := c.Manga("mrs-serie-100177863")
  if err != nil {
    log.Fatal(err)
  }
  fmt.Println(m.Name)
  // Fushigi Neko no Kyuu-chan
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithBase

func WithBase(base string) func(*Client)

WithBase sets the API base.

func WithHTTPClient

func WithHTTPClient(c *http.Client) func(*Client)

WithHTTPClient makes the manga client use a given http.Client to make requests.

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 a MangaRock Client.

func New

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

New returns a 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) (MangaSingle, 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) ([]Manga, error)

Search for mangas.

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 MangaSingle

type MangaSingle 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"`
}

MangaSingle 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