Documentation
¶
Index ¶
- Constants
- Variables
- func CleanString(s string) string
- func FloatIsInt(number float32) bool
- func FormattedFloat(n float32) string
- func GenericGetPageImage(ctx context.Context, client *http.Client, page Page) ([]byte, error)
- func Log(format string, a ...any)
- func ParseChapterTitle(s string) string
- func ReNamedGroups(pattern *regexp.Regexp, str string) map[string]string
- type Chapter
- type FilterOptions
- type Functions
- type HeadlessOptions
- type Loader
- type Manga
- type MangaDexOptions
- type MangaPlusCreatorsOptions
- type MangaPlusOptions
- type Options
- type Page
- type Provider
- func (p *Provider) ChapterPages(ctx context.Context, chapter mangadata.Chapter) ([]mangadata.Page, error)
- func (p *Provider) Close() error
- func (p *Provider) GetPageImage(ctx context.Context, page mangadata.Page) ([]byte, error)
- func (p *Provider) Info() libmangal.ProviderInfo
- func (p *Provider) MangaVolumes(ctx context.Context, manga mangadata.Manga) ([]mangadata.Volume, error)
- func (p *Provider) SearchMangas(ctx context.Context, query string) ([]mangadata.Manga, error)
- func (p *Provider) SetLogger(logger *logger.Logger)
- func (p *Provider) String() string
- func (p *Provider) VolumeChapters(ctx context.Context, volume mangadata.Volume) ([]mangadata.Chapter, error)
- type Store
- func (s *Store) Close() error
- func (s *Store) GetChapters(cacheID string, volume Volume, chapters *[]mangadata.Chapter) (bool, error)
- func (s *Store) GetMangas(cacheID string, query string, mangas *[]mangadata.Manga) (bool, error)
- func (s *Store) GetVolumes(cacheID string, manga Manga, volumes *[]mangadata.Volume) (bool, error)
- func (s *Store) SetChapters(cacheID string, chapters []mangadata.Chapter) error
- func (s *Store) SetMangas(cacheID string, mangas []mangadata.Manga) error
- func (s *Store) SetVolumes(cacheID string, volumes []mangadata.Volume) error
- type Volume
Constants ¶
const ( CacheBucketNameMangas = "mangas" CacheBucketNameVolumes = "volumes" CacheBucketNameChapters = "chapters" )
const ( VolumeNumberID = "vol_num" ChapterNumberID = "chap_num" PartNumberID = "part_num" ChapterTitleID = "title" MangaQueryID = "id" )
const BundleID = "mango"
Variables ¶
var ( MangaQueryIDRegex = regexp.MustCompile(`(?mi)\s*(m((anga)?[-_]?)?id)\s*:\s*(?P<` + MangaQueryID + `>.*\S)\s*$`) ChapterNumberRegex = regexp.MustCompile(numRe) ChapterNameRegex = regexp.MustCompile(`(?mi)^(` + volNumRe + `)?\s*` + chapNumRe + `\s*(` + sepRe + `\s*` + partNumRe + `)?\s*` + sepRe + `\s+` + chapNameRe + `\s*$`) // https://regex101.com/r/ADDouB ChapterNameExcludeRegex = regexp.MustCompile(`(?mi)^` + partNumRe + `$`) 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
Get the string with all whitespace standardized.
func FloatIsInt ¶ added in v0.10.3
FloatIsInt is a helper function to see if the float value is actually an integer.
func FormattedFloat ¶ added in v0.12.0
Get the float number with all of the insignificant digits removed.
For example, "001.500" becomes "1.5".
func GenericGetPageImage ¶ added in v0.9.0
func Log ¶ added in v0.5.3
Log calls (*lm.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 (*lm.Client).Logger()) and uses it for info display.
func ParseChapterTitle ¶ added in v0.16.1
func ReNamedGroups ¶ added in v0.10.0
Translate regex named groups to a map.
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 metadata.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() mangadata.ChapterInfo
func (*Chapter) MarshalJSON ¶ added in v0.5.0
type FilterOptions ¶ added in v0.13.0
type FilterOptions struct { // NSFW if the manga results should contain NSFW content. // // Only if the source allows to filter by NSFW. NSFW bool // Language of the manga results. // // Only if the source allows to filter by language. Language string // AvoidDuplicateChapters will not include duplicate // chapters in the results. AvoidDuplicateChapters bool // chapters in the results. // // Such as external sites for the chapters // (in the case of MangaDex that points to MangaPlus for example). ShowUnavailableChapters bool }
FilterOptions are general filtering options for all sources.
func DefaultFilterOptions ¶ added in v0.13.0
func DefaultFilterOptions() FilterOptions
func (*FilterOptions) String ¶ added in v0.13.0
func (f *FilterOptions) String() string
type Functions ¶ added in v0.5.3
type Functions struct { SearchMangas func(context.Context, Store, string) ([]mangadata.Manga, error) MangaVolumes func(context.Context, Store, Manga) ([]mangadata.Volume, error) VolumeChapters func(context.Context, Store, Volume) ([]mangadata.Chapter, error) ChapterPages func(context.Context, Store, Chapter) ([]mangadata.Page, error) GetPageImage func(context.Context, *http.Client, Page) ([]byte, error) }
type HeadlessOptions ¶ added in v0.13.0
type HeadlessOptions struct { // UseFlaresolverr if Flaresolverr should be used for the request. UseFlaresolverr bool // FlaresolverrURL the URL of the Flaresolverr API. FlaresolverrURL string }
HeadlessOptions are options that applied to the Headless browser, that some sources use for scraping.
func DefaultHeadlessOptions ¶ added in v0.13.0
func DefaultHeadlessOptions() HeadlessOptions
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
type Manga ¶ added in v0.5.0
type Manga struct { Title string `json:"title"` URL string `json:"url"` ID string `json:"id"` Cover string `json:"cover"` Banner string `json:"banner"` Metadata_ *metadata.Metadata `json:"-"` }
func (*Manga) MarshalJSON ¶ added in v0.5.0
func (*Manga) SetMetadata ¶ added in v0.12.0
type MangaDexOptions ¶ added in v0.13.0
type MangaDexOptions struct { // Options from the mangodex API package. mangodex.Options // DataSaver if lower quality images should be requested. DataSaver bool }
MangaDexOptions are options that apply to the MangaDex source.
func DefaultMangaDexOptions ¶ added in v0.13.0
func DefaultMangaDexOptions() MangaDexOptions
type MangaPlusCreatorsOptions ¶ added in v0.13.0
type MangaPlusCreatorsOptions struct { // Options from the mangoplus API package. creators.Options }
MangaPlusCreatorsOptions are options that apply to the MangaPlusCreators source.
func DefaultMangaPlusCreatorsOptions ¶ added in v0.13.0
func DefaultMangaPlusCreatorsOptions() MangaPlusCreatorsOptions
type MangaPlusOptions ¶ added in v0.10.2
type MangaPlusOptions struct { // Options from the mangoplus API package. mangoplus.Options // Quality of the images that should be requested. Quality string }
MangaPlusOptions are options that apply to the MangaPlus source.
func DefaultMangaPlusOptions ¶ added in v0.13.0
func DefaultMangaPlusOptions() MangaPlusOptions
type Options ¶ added in v0.5.0
type Options struct { // HTTPClient HTTP client to use for all requests. HTTPClient *http.Client // UserAgent to use for all HTTP requests. UserAgent string // CacheStore returns a gokv.Store implementation for use as a cache storage. CacheStore func(dbName, bucketName string) (gokv.Store, error) // Parallelism to use when making HTTP requests. Parallelism uint8 // Filter options. Filter FilterOptions // Headless options. Headless HeadlessOptions // MangaDex options MangaDex MangaDexOptions // MangaPlus options. MangaPlus MangaPlusOptions // MangaPlusCreators options. MangaPlusCreators MangaPlusCreatorsOptions }
Options are the general mangoprovider options.
func DefaultOptions ¶ added in v0.13.0
func DefaultOptions() Options
type Page ¶ added in v0.5.0
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 (*Provider) GetPageImage ¶ added in v0.5.0
func (*Provider) Info ¶ added in v0.5.0
func (p *Provider) Info() libmangal.ProviderInfo
func (*Provider) MangaVolumes ¶ added in v0.5.0
func (*Provider) SearchMangas ¶ added in v0.5.0
type Store ¶ added in v0.13.5
type Store struct {
// contains filtered or unexported fields
}
Store is a gokv.Store wrapper with special handling of search volumes/chapters as the manga needs to be re-setted when loading from the store, as the pointer of the manga will be different for all chapters and thus the SetMetadata method will not work.
func (*Store) GetChapters ¶ added in v0.13.5
func (*Store) GetVolumes ¶ added in v0.13.5
func (*Store) SetChapters ¶ added in v0.13.5
type Volume ¶ added in v0.5.0
func (*Volume) Info ¶ added in v0.5.0
func (v *Volume) Info() mangadata.VolumeInfo