mangoprovider

package module
v0.10.9 Latest Latest
Warning

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

Go to latest
Published: May 24, 2024 License: Unlicense Imports: 11 Imported by: 2

README

a logo depicting mango

ManGO Provider

Go Reference

Warning

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

Provider for libmangal written in go.

Most of the code/functionality is based heavily on implementations from Belphemur/mangal (which in turn comes from metafates/mangal) adapted to work with libmangal's mangal.

Credits

Mango logo: Mango icons created by max.icons - Flaticon

Documentation

Index

Constants

View Source
const (
	ChapterNumberIDName     = "chap_num"
	ChapterPartNumberIDName = "part_num"
	ChapterNameIDName       = "title"
	MangaQueryIDName        = "id"
)
View Source
const BundleID = "mango"

Variables

View Source
var (
	// Old, keeping them for quickly switching just in case
	// https://regex101.com/r/ADDouB
	// ChapterNameRegex       = regexp.MustCompile(`(?mi)chapter\s*#?\s*\d+(\.\d+)?\s*:\s*(.*\S)\s*$`)
	// ChapterNameRegex       = regexp.MustCompile(`(?mi)^([a-z]*\.?)\s*#?\s*\d+(\.\d+)?\s*[:\-_.]?\s+(?P<title>.*\S)\s*$`)
	// ChapterNameRegex       = regexp.MustCompile(`(?mi)^([a-z]*\.?)\s*#?\s*(?P<chap_num>\d+(\.\d+)?)\D\s*([:\-_.,]?\s*part\s*(?P<part_num>\d+))?\s*[:\-_.,]?\s*(?P<title>.*\S)\s*$`)
	MangaQueryIDRegex       = regexp.MustCompile(`(?mi)\s*(m((anga)?[-_]?)?id)\s*:\s*(?P<id>.*\S)\s*$`)
	ChapterNumberRegex      = regexp.MustCompile(`(?m)(\d+\.\d+|\d+)`)
	ChapterNumberMPRegex    = regexp.MustCompile(`(?m)(\d+-\d+|\d+\.\d+|\d+)`)
	ChapterNameRegex        = regexp.MustCompile(`(?mi)^([a-z]*\.?)\s*#?\s*(?P<chap_num>\d+(\.\d+)?)\s*([:\-_.,]?\s*part\s*(?P<part_num>\d+))?\s*[:\-_.,]?\s*(?P<title>\S.*\S)\s*$`)
	ChapterNameExcludeRegex = regexp.MustCompile(`(?mi)^part\s*#?\s*\d+(\.\d+)?$`)
	NewlineCharactersRegex  = regexp.MustCompile(`\r?\n`)
	ImageExtensionRegex     = regexp.MustCompile(`^\.[a-zA-Z0-9][a-zA-Z0-9.]*[a-zA-Z0-9]$`)
)

Functions

func CleanString added in v0.9.0

func CleanString(s string) string

Get the string with all whitespace standardized.

func FloatIsInt added in v0.10.3

func FloatIsInt(number float32) bool

FloatIsInt is a helper function to see if the float value is actually an integer.

func GenericGetPageImage added in v0.9.0

func GenericGetPageImage(
	ctx context.Context,
	client *http.Client,
	page Page,
) ([]byte, error)

func Log added in v0.5.3

func Log(msg string)

Log calls (*libmangal.Logger).Log(msg) when set, else it appends the message to the backlog. Once the logger is set, it logs all backlog on the next log.

It is the logger created by libmangal and used internally. Mangal also plugs into the logger (via (*libmangal.Client).Logger()) and uses it for info display.

func ReNamedGroups added in v0.10.0

func ReNamedGroups(pattern *regexp.Regexp, str string) map[string]string

Translate regex named groups to a map.

https://stackoverflow.com/a/53587770

Types

type Chapter added in v0.5.0

type Chapter struct {
	Title           string         `json:"title"`
	ID              string         `json:"id"`
	URL             string         `json:"url"`
	Number          float32        `json:"number"`
	Date            libmangal.Date `json:"date"`
	ScanlationGroup string         `json:"scanlation_group"`

	// AtHome is only required for mangadex
	AtHome  *mangodex.AtHomeServer `json:"-"`
	Volume_ *Volume                `json:"-"`
}

func (*Chapter) Info added in v0.5.0

func (c *Chapter) Info() libmangal.ChapterInfo

func (*Chapter) MarshalJSON added in v0.5.0

func (c *Chapter) MarshalJSON() ([]byte, error)

func (*Chapter) String added in v0.5.0

func (c *Chapter) String() string

func (*Chapter) Volume added in v0.5.0

func (c *Chapter) Volume() libmangal.Volume

type Filter added in v0.5.0

type Filter struct {
	NSFW                    bool
	Language                string
	MangaPlusQuality        string
	MangaDexDataSaver       bool
	TitleChapterNumber      bool
	AvoidDuplicateChapters  bool
	ShowUnavailableChapters bool
}

func (*Filter) String added in v0.5.0

func (f *Filter) String() string

type Functions added in v0.5.3

type Functions struct {
	SearchMangas   func(context.Context, gokv.Store, string) ([]libmangal.Manga, error)
	MangaVolumes   func(context.Context, gokv.Store, Manga) ([]libmangal.Volume, error)
	VolumeChapters func(context.Context, gokv.Store, Volume) ([]libmangal.Chapter, error)
	ChapterPages   func(context.Context, gokv.Store, Chapter) ([]libmangal.Page, error)
	GetPageImage   func(context.Context, *http.Client, Page) ([]byte, error)
}

type Headless added in v0.5.3

type Headless struct {
	UseFlaresolverr bool
	FlaresolverrURL string
}

type Loader added in v0.5.3

type Loader struct {
	libmangal.ProviderInfo
	Options Options
	F       func() Functions // So that the scrapers are loaded on ProviderLoader.Load(ctx)
}

func (*Loader) Info added in v0.5.3

func (l *Loader) Info() libmangal.ProviderInfo

func (*Loader) Load added in v0.5.3

func (l *Loader) Load(ctx context.Context) (libmangal.Provider, error)

func (*Loader) String added in v0.5.3

func (l *Loader) String() string

type Manga added in v0.5.0

type Manga struct {
	Title         string `json:"title"`
	AnilistSearch string `json:"anilist_search"`
	URL           string `json:"url"`
	ID            string `json:"id"`
	Cover         string `json:"cover"`
	Banner        string `json:"banner"`

	AnilistSet_ bool                   `json:"-"`
	Anilist_    libmangal.AnilistManga `json:"-"`
}

func (*Manga) AnilistManga added in v0.7.4

func (m *Manga) AnilistManga() (libmangal.AnilistManga, error)

func (*Manga) Info added in v0.5.0

func (m *Manga) Info() libmangal.MangaInfo

func (*Manga) MarshalJSON added in v0.5.0

func (m *Manga) MarshalJSON() ([]byte, error)

func (*Manga) SeriesJSON added in v0.7.4

func (m *Manga) SeriesJSON() (libmangal.SeriesJSON, bool, error)

func (*Manga) SetAnilistManga added in v0.7.4

func (m *Manga) SetAnilistManga(anilist libmangal.AnilistManga)

func (*Manga) String added in v0.5.0

func (m *Manga) String() string

type MangaPlusOptions added in v0.10.2

type MangaPlusOptions struct {
	OSVersion  string
	AppVersion string
	AndroidID  string
}

type Options added in v0.5.0

type Options struct {
	HTTPClient  *http.Client
	UserAgent   string
	HTTPStore   func(providerID string) (gokv.Store, error)
	Parallelism uint8
	Headless
	Filter
	MangaPlus MangaPlusOptions
}

type Page added in v0.5.0

type Page struct {
	Extension string            `json:"-"`
	URL       string            `json:"url"`
	Headers   map[string]string `json:"-"`
	Cookies   map[string]string `json:"-"`

	Chapter_ *Chapter `json:"-"`
}

func (*Page) Chapter added in v0.5.0

func (p *Page) Chapter() libmangal.Chapter

func (*Page) GetExtension added in v0.5.0

func (p *Page) GetExtension() string

func (*Page) String added in v0.5.0

func (p *Page) String() string

type Provider added in v0.5.0

type Provider struct {
	libmangal.ProviderInfo
	Options Options
	F       Functions
	// contains filtered or unexported fields
}

func (*Provider) ChapterPages added in v0.5.0

func (p *Provider) ChapterPages(
	ctx context.Context,
	chapter libmangal.Chapter,
) ([]libmangal.Page, error)

func (*Provider) Close added in v0.5.0

func (p *Provider) Close() error

func (*Provider) GetPageImage added in v0.5.0

func (p *Provider) GetPageImage(
	ctx context.Context,
	page libmangal.Page,
) ([]byte, error)

func (*Provider) Info added in v0.5.0

func (p *Provider) Info() libmangal.ProviderInfo

func (*Provider) MangaVolumes added in v0.5.0

func (p *Provider) MangaVolumes(
	ctx context.Context,
	manga libmangal.Manga,
) ([]libmangal.Volume, error)

func (*Provider) SearchMangas added in v0.5.0

func (p *Provider) SearchMangas(
	ctx context.Context,
	query string,
) ([]libmangal.Manga, error)

func (*Provider) SetLogger added in v0.5.0

func (p *Provider) SetLogger(_logger *libmangal.Logger)

func (*Provider) String added in v0.5.0

func (p *Provider) String() string

func (*Provider) VolumeChapters added in v0.5.0

func (p *Provider) VolumeChapters(
	ctx context.Context,
	volume libmangal.Volume,
) ([]libmangal.Chapter, error)

type Volume added in v0.5.0

type Volume struct {
	Number float32 `json:"number"`

	None   bool   `json:"-"`
	Manga_ *Manga `json:"-"`
}

func (*Volume) Info added in v0.5.0

func (v *Volume) Info() libmangal.VolumeInfo

func (*Volume) Manga added in v0.5.0

func (v *Volume) Manga() libmangal.Manga

func (*Volume) MarshalJSON added in v0.5.0

func (v *Volume) MarshalJSON() ([]byte, error)

func (*Volume) String added in v0.5.0

func (v *Volume) String() string

Jump to

Keyboard shortcuts

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