mangoplus

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

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

Go to latest
Published: Jun 20, 2026 License: MIT Imports: 17 Imported by: 0

README

mangoplus

Go Reference

Unofficial MangaPlus API Client.

Installation

go get github.com/raf555/mangoplus@latest

Usage

The simplest usage is as follows.

import "github.com/raf555/mangoplus"

client, err := mangoplus.NewClient()
if err != nil {
    // handle error
}

_, err = client.Register(context.Background())
if err != nil {
    // handle error
}

manga, err := client.Title.GetTitleDetailV3(context.Background(), 100185)
if err != nil {
    // handle error
}

Contributing

See CONTRIBUTING.md.

Disclaimer

[!WARNING]
this package is an unofficial API wrapper for the MangaPlus android application and is not affiliated with, endorsed by, or sponsored by Shueisha or MangaPlus. "MangaPlus" and all related content are trademarks of their respective owners. The API is undocumented and may change or break at any time. Use of this package may be subject to MangaPlus's Terms of Service; users are responsible for ensuring their use complies with applicable terms and laws.

Documentation

Overview

package mangoplus provides a client for using MangaPlus API.

Usage:

import "github.com/raf555/mangoplus"

client, err := mangoplus.NewClient()
// handle error
secret, err := client.Register(ctx)

Client.Register call is required unless you specify the secret via WithSecret option or using WithAutoRegister option. Example:

client, err := mangoplus.NewClient(mangoplus.WithSecret("some_secret"))

or

client, err := mangoplus.NewClient(mangoplus.WithAutoRegister(context.Background()))

Disclaimer: this package is an unofficial API wrapper for the MangaPlus android application and is not affiliated with, endorsed by, or sponsored by Shueisha or MangaPlus. "MangaPlus" and all related content are trademarks of their respective owners. The API is undocumented and may change or break at any time. Use of this package may be subject to MangaPlus's Terms of Service; users are responsible for ensuring their use complies with applicable terms and laws.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound is an error when MangaPlus returned proto error with Not Found subject.
	ErrNotFound = errors.New("mangoplus: not found")

	// ErrInvalidParameter is an error when MangaPlus returned proto error with Invalid Parameter subject.
	ErrInvalidParameter = errors.New("mangoplus: invalid parameter")

	// ErrNewVersionAvailable is an error when MangaPlus returned proto error with NEW VERSION AVAILABLE subject.
	ErrNewVersionAvailable = errors.New("mangoplus: new version available")

	// ErrInvalidUserAccess is an error when MangaPlus returned proto error with Invalid user subject.
	ErrInvalidUserAccess = errors.New("mangoplus: invalid user access")
)

Functions

This section is empty.

Types

type APIError

type APIError struct {
	StatusCode int
	Headers    http.Header
	RawBody    []byte
}

APIError is an error returned when MangaPlus API returns non-200 status code.

func (*APIError) Error

func (a *APIError) Error() string

type AllTitlesGroupV2

type AllTitlesGroupV2 struct {
	TheTitle string
	Titles   []Title
}

type AllTitlesViewV2

type AllTitlesViewV2 struct {
	AllTitlesGroup []AllTitlesGroupV2
}

type Chapter

type Chapter struct {
	TitleID                   int
	ChapterID                 int
	Name                      string
	SubTitle                  string
	ThumbnailURL              string
	StartTimestamp            time.Time
	EndTimestamp              time.Time
	AlreadyViewed             bool
	IsVerticalOnly            bool
	ChapterTicketEndTimestamp time.Time
	ViewedForFree             bool
	IsHorizontalOnly          bool
	ViewCount                 int
	CommentCount              int
	IsUpdated                 bool
	ChapterType               ChapterType
}

type ChapterGroup

type ChapterGroup struct {
	ChapterNumbers   string
	FirstChapterList []Chapter
	MidChapterList   []Chapter
	LastChapterList  []Chapter
}

type ChapterType

type ChapterType string
const (
	ChapterTypeFree                ChapterType = "FREE"
	ChapterTypeFreeForFirstTime    ChapterType = "FREE_FOR_FIRST_TIME"
	ChapterTypeStandard            ChapterType = "STANDARD"
	ChapterTypeDeluxe              ChapterType = "DELUXE"
	ChapterTypeLockedAfterFreeRead ChapterType = "LOCKED_AFTER_FREE_READ"
)

type Client

type Client struct {
	Registration *RegistrationService
	TitleList    *TitleListService
	Title        *TitleService
	Manga        *MangaService
	// contains filtered or unexported fields
}

Client is a wrapper for MangaPlus APIs.

Note: Services do not guarantee all fields are populated, some response fields may be unpopulated / zero value. Callers are responsible for handling this appropriately.

func NewClient

func NewClient(opts ...ClientOptionsFunc) (*Client, error)

NewClient returns a new Client configured with the provided ClientOptionsFunc. Default configuration of Client is ready to use after Client.Register call is successful.

It is recommended to provide secret via WithSecret option if you already have it / have already registered it previously.

func (*Client) CookieJar

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

CookieJar returns http.CookieJar used by Client.

func (*Client) NewRequest

func (c *Client) NewRequest(ctx context.Context, method string, u string, opts ...RequestOptionsFunc) (*http.Request, error)

NewRequest creates a new http.Request with necessary information attached to it. Additional data may be provided via RequestOptionsFunc if needed.

If `u` has prefix `/`, it is assumed to be a URL path and part of the Client base URL. Otherwise, it'll be treated as-is.

func (*Client) Register

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

Register registers current Client to MangaPlus. It also sets and returns Client's secret when successfully called.

Register is noop when secret key is already set.

func (*Client) Secret

func (c *Client) Secret() string

Secret returns secret key used by Client for communicating with MangaPlus API.

It may be empty if not registered yet.

type ClientOptionsFunc

type ClientOptionsFunc func(*clientOptions) error

ClientOptionsFunc is a functional option for providing configuration options to a Client.

func WithAndroidID

func WithAndroidID(androidID string) ClientOptionsFunc

WithAndroidID returns a ClientOptionsFunc that sets the android ID for a Client. If not set, a random android ID will be generated.

Android ID is used for registering the client to retrieve the MangaPlus secret. If secret is already provided, NewClient may return error.

func WithAppVersion

func WithAppVersion(appVer string) ClientOptionsFunc

WithAppVersion returns a ClientOptionsFunc that sets the app version for a Client. If not set, a default app version will be used.

func WithAutoRegister

func WithAutoRegister(ctx context.Context) ClientOptionsFunc

WithAutoRegister returns a ClientOptionsFunc that sets auto registeration for Client. This option is noop when secret is provided.

For example:

client, err := NewClient()
_, err = client.Register(context.Background())

is equivalent to

client, err := NewClient(WithAutoRegister(context.Background()))

func WithCookieJar

func WithCookieJar(cookieJar http.CookieJar) ClientOptionsFunc

WithCookieJar returns a ClientOptionsFunc that sets the http.CookieJar for a Client. This overrides the cookie jar set by WithHTTPClient. If not set and no HTTP client is provided, the Client will use its own http.CookieJar which then is retriveable from Client.CookieJar.

func WithHTTPClient

func WithHTTPClient(httpClient *http.Client) ClientOptionsFunc

WithHTTPClient returns a ClientOptionsFunc that sets the http.Client for a Client. If not set, a default http.Client will be used.

func WithOSVersion

func WithOSVersion(osVer string) ClientOptionsFunc

WithOSVersion returns a ClientOptionsFunc that sets the OS version for a Client. If not set, a default OS version will be used.

func WithSecret

func WithSecret(secret string) ClientOptionsFunc

WithSecret returns a ClientOptionsFunc that sets the secret for a Client. If not set, android ID will be used for registration.

Secret is used for communicating with the MangaPlus APIs. If Android ID is already provided, NewClient may return error.

func WithTimeout

func WithTimeout(timeout time.Duration) ClientOptionsFunc

WithTimeout returns a ClientOptionsFunc that sets the timeout for a Client. This overrides the timeout set by WithHTTPClient. If not set and no HTTP client is provided, the default http.Client with no timeout will be used.

func WithTransport

func WithTransport(transport http.RoundTripper) ClientOptionsFunc

WithTransport returns a ClientOptionsFunc that sets the http.RoundTripper for a Client. This overrides the transport set by WithHTTPClient. If not set and no HTTP client is provided, the default http.RoundTripper will be used.

func WithUserAgent

func WithUserAgent(userAgent string) ClientOptionsFunc

WithUserAgent returns a ClientOptionsFunc that sets the User-Agent header for a Client. If not set, a default User-Agent will be used.

type ErrorAction

type ErrorAction string
const (
	ErrorActionDefault       ErrorAction = "DEFAULT"
	ErrorActionUnauthorized  ErrorAction = "UNAUTHORIZED"
	ErrorActionMaintenance   ErrorAction = "MAINTENANCE"
	ErrorActionGeoIPBlocking ErrorAction = "GEOIP_BLOCKING"
)

type ImageQuality

type ImageQuality string
const (
	ImageQualityLow       ImageQuality = "low"
	ImageQualityHigh      ImageQuality = "high"
	ImageQualitySuperHigh ImageQuality = "super_high"
)

type Label

type Label struct {
	Code        LabelCode
	Description string
}

type LabelCode

type LabelCode string
const (
	LabelCodeWJ       LabelCode = "WJ"
	LabelCodeSQ       LabelCode = "SQ"
	LabelCodeVJ       LabelCode = "VJ"
	LabelCodeYJ       LabelCode = "YJ"
	LabelCodeJPlus    LabelCode = "J_PLUS"
	LabelCodeRevival  LabelCode = "REVIVAL"
	LabelCodeCreators LabelCode = "CREATORS"
	LabelCodeMEE      LabelCode = "MEE"
	LabelCodeTYJ      LabelCode = "TYJ"
	LabelCodeOthers   LabelCode = "OTHERS"
	LabelCodeSKJ      LabelCode = "SKJ"
	LabelCodeGiga     LabelCode = "GIGA"
	LabelCodeUJ       LabelCode = "UJ"
	LabelCodeDX       LabelCode = "DX"
)

type Language

type Language string
const (
	LanguageEnglish      Language = "ENGLISH"
	LanguageSpanish      Language = "SPANISH"
	LanguageFrench       Language = "FRENCH"
	LanguageIndonesian   Language = "INDONESIAN"
	LanguagePortugueseBR Language = "PORTUGUESE_BR"
	LanguageRussian      Language = "RUSSIAN"
	LanguageThai         Language = "THAI"
	LanguageVietnamese   Language = "VIETNAMESE"
	LanguageGerman       Language = "GERMAN"
)

type MangaAvailableLanguage

type MangaAvailableLanguage struct {
	TitleID  int
	Language Language
}

type MangaPage

type MangaPage struct {
	ImageURL      string
	Width         int
	Height        int
	Type          PageType
	EncryptionKey string
}

type MangaService

type MangaService service

MangaService wraps Manga related APIs.

func (*MangaService) ViewChapter

func (m *MangaService) ViewChapter(ctx context.Context, chapterID int, opts ViewChapterOptions) (MangaViewer, error)

type MangaViewer

type MangaViewer struct {
	MangaPages     []MangaPage
	CurrentChapter Chapter

	ChapterID          int
	TitleName          string
	ChapterName        string
	NumberOfComments   int
	TitleID            int
	TitleLanguage      Language
	AvailableLanguages []MangaAvailableLanguage
	StartFromRight     bool
	IsVerticalOnly     bool
	IsHorizontalOnly   bool
}

type PageType

type PageType string
const (
	PageTypeSingle PageType = "SINGLE"
	PageTypeLeft   PageType = "LEFT"
	PageTypeRight  PageType = "RIGHT"
	PageTypeDouble PageType = "DOUBLE"
)

type PopupOsDefault

type PopupOsDefault struct {
	Subject  string
	Body     string
	Language Language
}

type ProtoError

type ProtoError struct {
	Action       ErrorAction
	EnglishPopup PopupOsDefault
	DebugInfo    string
	Popups       []PopupOsDefault
}

ProtoError is an error returned when MangaPlus API returns an error response.

func (*ProtoError) Error

func (p *ProtoError) Error() string

func (*ProtoError) Is

func (p *ProtoError) Is(target error) bool

type Rating

type Rating string
const (
	RatingAllAges  Rating = "ALLAGES"
	RatingTeen     Rating = "TEEN"
	RatingTeenPlus Rating = "TEENPLUS"
	RatingMature   Rating = "MATURE"
)

type RegistrationData

type RegistrationData struct {
	DeviceSecret string
}

type RegistrationService

type RegistrationService service

RegistrationService wraps registration APIs.

func (*RegistrationService) Register

func (r *RegistrationService) Register(ctx context.Context, deviceToken, securityKey string) (RegistrationData, error)

Register registers provided device token and security key to MangaPlus. It returns a device secret usable for most MangaPlus API.

type ReleaseSchedule

type ReleaseSchedule string
const (
	ReleaseScheduleDisabled   ReleaseSchedule = "DISABLED"
	ReleaseScheduleEveryday   ReleaseSchedule = "EVERYDAY"
	ReleaseScheduleWeekly     ReleaseSchedule = "WEEKLY"
	ReleaseScheduleBiweekly   ReleaseSchedule = "BIWEEKLY"
	ReleaseScheduleMonthly    ReleaseSchedule = "MONTHLY"
	ReleaseScheduleBiMonthly  ReleaseSchedule = "BIMONTHLY"
	ReleaseScheduleTriMonthly ReleaseSchedule = "TRIMONTHLY"
	ReleaseScheduleOther      ReleaseSchedule = "OTHER"
	ReleaseScheduleCompleted  ReleaseSchedule = "COMPLETED"
	ReleaseScheduleOneShot    ReleaseSchedule = "ONE_SHOT"
	ReleaseScheduleHiatus     ReleaseSchedule = "HIATUS"
)

type RequestOptionsFunc

type RequestOptionsFunc func(*requestOptions) error

func WithRequestBody

func WithRequestBody(contentType string, b io.Reader) RequestOptionsFunc

func WithoutSecret

func WithoutSecret() RequestOptionsFunc

WithoutSecret instructs [NewRequest] to omit the client secret from the request query params.

type Tag

type Tag struct {
	Name string
	Slug string
}

type Title

type Title struct {
	TitleID           int
	Name              string
	Author            string
	PortraitImageURL  string
	LandscapeImageURL string
	Language          Language
}

type TitleDetailView

type TitleDetailView struct {
	Title              Title
	ImageURL           string
	Overview           string
	BackgroundImageURL string
	TitleImageURL      string
	NextTimestamp      time.Time
	IsSimulRelease     bool
	Rating             Rating
	NumberOfViews      int
	Languages          []TitleLanguage
	Tags               []Tag
	Labels             TitleLabels
	Label              Label
	ChapterListGroup   []ChapterGroup
	ChapterListV2      []Chapter
}

type TitleLabels

type TitleLabels struct {
	ReleaseSchedule ReleaseSchedule
	IsSimulpub      bool
}

type TitleLanguage

type TitleLanguage struct {
	TitleID  int
	Language Language
}

type TitleListService

type TitleListService service

TitleListService wraps Title list related APIs.

func (*TitleListService) AllV2

type TitleService

type TitleService service

TitleService wraps Title related APIs.

func (*TitleService) GetTitleDetailV3

func (t *TitleService) GetTitleDetailV3(ctx context.Context, titleID int) (TitleDetailView, error)

type ViewChapterOptions

type ViewChapterOptions struct {
	SplitImages  bool
	ImageQuality ImageQuality
}

func DefaultViewChapterOptions

func DefaultViewChapterOptions() ViewChapterOptions

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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