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 ¶
- Variables
- type APIError
- type AllTitlesGroupV2
- type AllTitlesViewV2
- type Chapter
- type ChapterGroup
- type ChapterType
- type Client
- type ClientOptionsFunc
- func WithAndroidID(androidID string) ClientOptionsFunc
- func WithAppVersion(appVer string) ClientOptionsFunc
- func WithAutoRegister(ctx context.Context) ClientOptionsFunc
- func WithCookieJar(cookieJar http.CookieJar) ClientOptionsFunc
- func WithHTTPClient(httpClient *http.Client) ClientOptionsFunc
- func WithOSVersion(osVer string) ClientOptionsFunc
- func WithSecret(secret string) ClientOptionsFunc
- func WithTimeout(timeout time.Duration) ClientOptionsFunc
- func WithTransport(transport http.RoundTripper) ClientOptionsFunc
- func WithUserAgent(userAgent string) ClientOptionsFunc
- type ErrorAction
- type ImageQuality
- type Label
- type LabelCode
- type Language
- type MangaAvailableLanguage
- type MangaPage
- type MangaService
- type MangaViewer
- type PageType
- type PopupOsDefault
- type ProtoError
- type Rating
- type RegistrationData
- type RegistrationService
- type ReleaseSchedule
- type RequestOptionsFunc
- type Tag
- type Title
- type TitleDetailView
- type TitleLabels
- type TitleLanguage
- type TitleListService
- type TitleService
- type ViewChapterOptions
Constants ¶
This section is empty.
Variables ¶
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 AllTitlesGroupV2 ¶
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 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 ¶
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.
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" ErrorActionMaintenance ErrorAction = "MAINTENANCE" ErrorActionGeoIPBlocking ErrorAction = "GEOIP_BLOCKING" )
type ImageQuality ¶
type ImageQuality string
const ( ImageQualityLow ImageQuality = "low" ImageQualityHigh ImageQuality = "high" ImageQualitySuperHigh ImageQuality = "super_high" )
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 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 PopupOsDefault ¶
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 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 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 TitleListService ¶
type TitleListService service
TitleListService wraps Title list related APIs.
func (*TitleListService) AllV2 ¶
func (t *TitleListService) AllV2(ctx context.Context) (AllTitlesViewV2, error)
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