mangoplus

package module
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2024 License: MIT Imports: 10 Imported by: 2

README

mangoplus

Golang API wrapper for MangaPlus API and MangaPlusCreators API.

There's no API documentation so most of the implementation is just winging it.

Warning

The API implementation is not stable and may change at any time.

Installation

To install, do go get -u github.com/luevano/mangoplus@latest.

Usage

Basic usage example.

package main

import (
    "fmt"
    "net/url"

    "github.com/luevano/mangoplus"
)

func main() {
    // Create new client.
    c := mangoplus.NewPlusClient(mangoplus.DefaultOptions())

    // ID for Ghost Fixers.
    id := 100310

    // Get manga by id.
    mangaDetails, err := c.Manga.Get(id)
    if err != nil {
        panic(err)
    }
    for _, chapter := range mangaDetails.ChapterListGroup {
        for _, c := range chapter.FirstChapterList {
            fmt.Println(c.Name)
        }
    }
}

Contributing

Any contributions are welcome.

Documentation

Overview

Package mangoplus provides an API wrapper for MangaPlus API.

Index

Constants

View Source
const (
	BaseAPI    = "https://jumpg-api.tokyo-cdn.com/api"
	BaseWebAPI = "https://jumpg-webapi.tokyo-cdn.com/api" // Limited to what's available on the browser
	OriginURL  = "https://mangaplus.shueisha.co.jp"       // Not used
)
View Source
const (
	AllMangaPath = "title_list/allV2"
	MangaPath    = "title_detailV3"
)
View Source
const (
	PagePath = "manga_viewer"
)
View Source
const RegisterPath = "register"

Variables

This section is empty.

Functions

This section is empty.

Types

type AllTitlesGroup

type AllTitlesGroup struct {
	TheTitle string  `json:"theTitle"`
	Titles   []Title `json:"titles"`
}

type AllTitlesViewV2

type AllTitlesViewV2 struct {
	AllTitlesGroup []AllTitlesGroup `json:"allTitlesGroup"`
}

type Chapter

type Chapter struct {
	TitleId        int     `json:"titleId"`
	ChapterId      int     `json:"chapterId"`
	Name           string  `json:"name"`
	SubTitle       *string `json:"subTitle"`
	ThumbnailUrl   string  `json:"thumbnailUrl"`
	StartTimeStamp int     `json:"startTimeStamp"`
	EndTimeStamp   int     `json:"endTimeStamp"`
	AlreadyViewed  bool    `json:"alreadyViewed"`
	ViewCount      int     `json:"viewCount"`
	CommentCount   int     `json:"commentCount"`
	IsVerticalOnly bool    `json:"isVerticalOnly"`
}

type ChapterListGroup

type ChapterListGroup struct {
	ChapterNumbers   string    `json:"chapterNumbers"`
	FirstChapterList []Chapter `json:"firstChapterList"`
	MidChapterList   []Chapter `json:"midChapterList"`
	LastChapterList  []Chapter `json:"lastChapterList"`
}

type ErrorResponse

type ErrorResponse struct {
	// Not sure if English/Spanish are always the ones that
	// appear on top, could be specific to me.
	EnglishPopup *Popup   `json:"englishPopup"`
	SpanishPopup *Popup   `json:"spanishPopup"`
	Popups       *[]Popup `json:"popups"`
}

ErrorResponse: Generic error response.

func (*ErrorResponse) GetErrors

func (error *ErrorResponse) GetErrors() string

TODO: handle one specific language instead of the first in the list

GetErrors: Get the errors for this particular request.

type ImageQuality added in v0.2.0

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

func StringToImageQuality added in v0.2.1

func StringToImageQuality(str string) ImageQuality

StringToImageQuality: Get the corresponding ImageQuality given a string.

Defaults to ImageQualitySuperHigh.

type Label

type Label struct {
	Label LabelCode `json:"label"`
}

func (Label) Long added in v0.2.0

func (l Label) Long() string

type LabelCode added in v0.2.0

type LabelCode string
const (
	LabelCodeCreators LabelCode = "CREATORS"
	LabelCodeGiga     LabelCode = "GIGA"
	LabelCodeJPlus    LabelCode = "J_PLUS"
	LabelCodeOthers   LabelCode = "OTHERS"
	LabelCodeRevival  LabelCode = "REVIVAL"
	LabelCodeSKJ      LabelCode = "SKJ"
	LabelCodeSQ       LabelCode = "SQ"
	LabelCodeTYJ      LabelCode = "TYJ"
	LabelCodeVJ       LabelCode = "VJ"
	LabelCodeYJ       LabelCode = "YJ"
	LabelCodeWSJ      LabelCode = "WSJ"
)

type Language added in v0.2.0

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"
)

func StringToLanguage added in v0.2.1

func StringToLanguage(languageCode string) Language

StringToLanguage: Get the corresponding Language type from a Language code.

Defaults to LanguageEnglish.

Using MangaDex as reference: https://api.mangadex.org/docs/3-enumerations/#language-codes--localization

func (Language) ToCode added in v0.2.0

func (l Language) ToCode() string

ToCode: Get the corresponding Language code.

Defaults to "en".

Using MangaDex as reference: https://api.mangadex.org/docs/3-enumerations/#language-codes--localization

type Languages

type Languages struct {
	DefaultUILanguage         Language `json:"defaultUiLanguage"`
	DefaultContentLanguageOne Language `json:"defaultContentLanguageOne"`
	AvailableLanguages        []struct {
		Language    *Language `json:"language"`
		TitlesCount int       `json:"titlesCount"`
	} `json:"availableLanguages"`
}

Languages: Part of the response when requesting all of the manga.

Not really used.

type MangaPage

type MangaPage struct {
	ImageURL      string  `json:"imageUrl"`
	Width         int     `json:"width"`
	Height        int     `json:"height"`
	Type          *string `json:"type"` // Could be "DOUBLE" (double paged)
	EncryptionKey *string `json:"encryptionKey"`
}

type MangaService

type MangaService service

MangaService: Provides Manga services provided by the API.

func (*MangaService) All

func (s *MangaService) All() ([]AllTitlesGroup, error)

All: Get list of all manga.

func (*MangaService) Get

func (s *MangaService) Get(id string) (TitleDetailView, error)

Get: Get manga details by ID.

type MangaViewer

type MangaViewer struct {
	Pages            []Page    `json:"pages"`
	ChapterID        int       `json:"chapterId"`
	Chapters         []Chapter `json:"chapters"` // Probably not really needed
	TitleName        string    `json:"titleName"`
	ChapterName      string    `json:"chapterName"`
	NumberOfComments int       `json:"numberOfComments"`
	TitleID          int       `json:"titleId"`
	RegionCode       string    `json:"regionCode"`
	TitleLanguage    string    `json:"titleLanguage"` // This uses a completely different format than that of other Language fields
}

type Options added in v0.3.1

type Options struct {
	UserAgent  string
	OSVersion  string
	AppVersion string
	AndroidID  string
}

func DefaultOptions added in v0.3.1

func DefaultOptions() Options

type Page

type Page struct {
	MangaPage *MangaPage `json:"mangaPage"`
}

type PageService

type PageService service

PageService: Provides Page services provided by the API.

func (*PageService) Get

func (s *PageService) Get(id string, splitImages bool, imageQuality ImageQuality) ([]MangaPage, error)

Get: Get list of all chapter pages.

type PlusClient

type PlusClient struct {

	// Services for MangaPlus API.
	Manga *MangaService
	Page  *PageService
	// contains filtered or unexported fields
}

PlusClient: The MangaPlus client.

func NewPlusClient

func NewPlusClient(options Options) *PlusClient

NewPlusClient: New MangaPlus client.

Options must be non-nil. Use DefaultOptions for defaults, all fields must be non-empty.

func (*PlusClient) Request

func (c *PlusClient) Request(
	ctx context.Context,
	method string,
	url url.URL,
	params map[string]string,
	headers map[string]string,
	body io.Reader,
) (PlusResponse, error)

Request: Sends a request to the MangaPlus API and decodes into a PlusResponse.

type PlusResponse

type PlusResponse struct {
	Success *SuccessResponse `json:"success"`
	Error   *ErrorResponse   `json:"error"`
}

PlusResponse: Generic MangaPlus API response type, most responses have this structure.

type Popup struct {
	Subject      string `json:"subject"`
	Body         string `json:"body"`
	CancelButton struct {
		Text string `json:"text"`
	} `json:"cancelButton"`
	Language *Language `json:"language"`
}

type Rating added in v0.2.0

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

type RegisterationData added in v0.3.0

type RegisterationData struct {
	DeviceSecret string `json:"deviceSecret"`
}

type ReleaseSchedule added in v0.2.0

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"
)

type SuccessResponse

type SuccessResponse struct {
	IsFeaturedUpdated *bool              `json:"isFeaturedUpdated"`
	RegisterationData *RegisterationData `json:"registerationData"`
	TitleDetailView   *TitleDetailView   `json:"titleDetailView"`
	MangaViewer       *MangaViewer       `json:"mangaViewer"`
	AllTitlesViewV2   *AllTitlesViewV2   `json:"allTitlesViewV2"`
	Languages         *Languages         `json:"languages"`
}

SuccessResponse: Generic success response.

type Title

type Title struct {
	TitleID           int       `json:"titleId"`
	Name              string    `json:"name"`
	Author            string    `json:"author"`
	PortraitImageURL  string    `json:"portraitImageUrl"`
	Language          *Language `json:"language"`
	ViewCount         *int      `json:"viewCount"`
	TitleUpdateStatus *string   `json:"titleUpdateStatus"`
}

type TitleDetailView

type TitleDetailView struct {
	Title                    Title              `json:"title"`
	TitleImageUrl            string             `json:"titleImageUrl"`
	Overview                 string             `json:"overview"`
	NextTimeStamp            int                `json:"nextTimeStamp"`
	ViewingPeriodDescription string             `json:"viewingPeriodDescription"`
	ChapterListGroup         []ChapterListGroup `json:"chapterListGroup"`
	IsSimulReleased          bool               `json:"isSimulReleased"`
	Rating                   Rating             `json:"rating"`
	NumberOfViews            int                `json:"numberOfViews"`
	RegionCode               string             `json:"regionCode"`
	TitleLabels              TitleLabels        `json:"titleLabels"`
	Label                    *Label             `json:"label"`
	IsFirstTimeFree          bool               `json:"isFirstTimeFree"`
}

type TitleLabels

type TitleLabels struct {
	ReleaseSchedule ReleaseSchedule `json:"releaseSchedule"`
	IsSimulpub      bool            `json:"isSimulpub"`
	PlanType        string          `json:"planType"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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