mangoplus

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 18, 2024 License: MIT Imports: 8 Imported by: 2

README

mangoplus

Golang API wrapper for MangaPlus 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()

    // 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 (
	OriginURL = "https://mangaplus.shueisha.co.jp"
	BaseAPI   = "https://jumpg-webapi.tokyo-cdn.com/api"
)
View Source
const (
	AllMangaPath = "title_list/allV2"
	MangaPath    = "title_detailV3"
)
View Source
const (
	PagePath = "manga_viewer"
)

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"` // Not really required, these aren't downloadable
	LastChapterList  []Chapter `json:"lastChapterList"`
}

type ErrorResponse

type ErrorResponse struct {
	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 Label

type Label struct {
	Label string `json:"label"` // Make this a special type
}

type Languages

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

type MangaPage

type MangaPage struct {
	ImageURL      string  `json:"imageUrl"`
	Width         int     `json:"width"`
	Height        int     `json:"height"`
	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"`
}

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 string) ([]MangaPage, error)

TODO: Make imageQuality a special type.

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() *PlusClient

NewPlusClient: New MangaPlus client.

func (*PlusClient) Request

func (c *PlusClient) Request(ctx context.Context, method, url 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 *string `json:"language"`
}

type SuccessResponse

type SuccessResponse struct {
	IsFeaturedUpdated *bool            `json:"isFeaturedUpdated"`
	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          *string `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                   string             `json:"rating"`
	NumberOfViews            int                `json:"numberOfViews"`
	RegionCode               string             `json:"regionCode"`
	Label                    *Label             `json:"label"`
	IsFirstTimeFree          bool               `json:"isFirstTimeFree"`
}

type TitleLabels

type TitleLabels struct {
	ReleaseSchedule string `json:"releaseSchedule"` // Make this a special type
	IsSimulpub      bool   `json:"isSimulpub"`
	PlanType        string `json:"planType"`
}

Jump to

Keyboard shortcuts

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