source

package
v0.0.0-...-24eef8c Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2024 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Chapter

type Chapter struct {
	// Name of the chapter
	Name string `json:"name" jsonschema:"description=Name of the chapter"`
	// Number represent the chapter number like 145.5 0.5
	Number float32 `json:"number" jsonschema:"description=Number of the chapter as defined in its source"`
	// URL of the chapter
	URL string `json:"url" jsonschema:"description=URL of the chapter"`
	// Index of the chapter in the manga.
	Index uint16 `json:"index" jsonschema:"description=Index of the chapter in the manga"`
	// ID of the chapter in the source.
	ID string `json:"id" jsonschema:"description=ID of the chapter in the source"`
	// Volume which the chapter belongs to.
	Volume string `json:"volume" jsonschema:"description=Volume which the chapter belongs to"`
	// Manga that the chapter belongs to.
	Manga *Manga `json:"-"`
	// Pages of the chapter.
	Pages []*Page `json:"pages" jsonschema:"description=Pages of the chapter"`
	// Date when the chapter was released.
	ChapterDate *time.Time `json:"chapter_date" jsonschema:"description=Date when the chapter was released"`
	// Scanlations team that translated the chapter.
	Scanlations []string `json:"scanlation,omitempty" jsonschema:"description=Scanlations team(s) that translated the chapter"`
	// contains filtered or unexported fields
}

Chapter is a struct that represents a chapter of a manga.

func (*Chapter) ComicInfo

func (c *Chapter) ComicInfo() *ComicInfo

func (*Chapter) DownloadPages

func (c *Chapter) DownloadPages(temp bool, progress func(string)) (err error)

DownloadPages downloads the Pages contents of the Chapter. Pages needs to be set before calling this function.

func (*Chapter) Filename

func (c *Chapter) Filename() (filename string)

func (*Chapter) IsDownloaded

func (c *Chapter) IsDownloaded() bool

func (*Chapter) Path

func (c *Chapter) Path(temp bool) (path string, err error)

func (*Chapter) SizeHuman

func (c *Chapter) SizeHuman() string

SizeHuman is the same as Size but returns a human-readable string.

func (*Chapter) Source

func (c *Chapter) Source() Source

func (*Chapter) String

func (c *Chapter) String() string

func (*Chapter) UpdatePages

func (c *Chapter) UpdatePages(pages []*Page)

type ComicInfo

type ComicInfo struct {
	XMLName  xml.Name `xml:"ComicInfo"`
	XmlnsXsi string   `xml:"xmlns:xsi,attr"`
	XmlnsXsd string   `xml:"xmlns:xsd,attr"`

	// General
	Title      string `xml:"Title,omitempty"`
	Series     string `xml:"Series,omitempty"`
	Number     string `xml:"Number,omitempty"`
	Web        string `xml:"Web,omitempty"`
	Genre      string `xml:"Genre,omitempty"`
	PageCount  int    `xml:"PageCount,omitempty"`
	Summary    string `xml:"Summary,omitempty"`
	Count      int    `xml:"Count,omitempty"`
	Characters string `xml:"Characters,omitempty"`
	Year       int    `xml:"Year,omitempty"`
	Month      int    `xml:"Month,omitempty"`
	Day        int    `xml:"Day,omitempty"`
	Writer     string `xml:"Writer,omitempty"`
	Penciller  string `xml:"Penciller,omitempty"`
	Letterer   string `xml:"Letterer,omitempty"`
	Translator string `xml:"Translator,omitempty"`
	Tags       string `xml:"Tags,omitempty"`
	Notes      string `xml:"Notes,omitempty"`
	Manga      string `xml:"Manga,omitempty"`
	Teams      string `xml:"Teams,omitempty"`
}

type Manga

type Manga struct {
	// Name of the manga
	Name string `json:"name" jsonschema:"description=Name of the manga"`
	// URL of the manga
	URL string `json:"url" jsonschema:"description=URL of the manga"`
	// Index of the manga in the source.
	Index uint16 `json:"index" jsonschema:"description=Index of the manga in the source"`
	// ID of manga in the source.
	ID string `json:"id" jsonschema:"description=ID of manga in the source"`
	// Chapters of the manga
	Chapters []*Chapter `json:"chapters" jsonschema:"description=Chapters of the manga"`
	// Source that the manga belongs to.
	Source Source `json:"-"`
	// Anilist is the closest anilist match
	Anilist  mo.Option[*anilist.Manga] `json:"-"`
	Metadata struct {
		// Genres of the manga
		Genres []string `json:"genres" jsonschema:"description=Genres of the manga"`
		// Summary in the plain text with newlines
		Summary string `json:"summary" jsonschema:"description=Summary in the plain text with newlines"`
		// Staff that worked on the manga
		Staff struct {
			// Story authors
			Story []string `json:"story" jsonschema:"description=Story authors"`
			// Art authors
			Art []string `json:"art" jsonschema:"description=Art authors"`
			// Translation group
			Translation []string `json:"translation" jsonschema:"description=Translation group"`
			// Lettering group
			Lettering []string `json:"lettering" jsonschema:"description=Lettering group"`
		} `json:"staff" jsonschema:"description=Staff that worked on the manga"`
		// Cover images of the manga
		Cover struct {
			// ExtraLarge is the largest cover image. If not available, Large will be used.
			ExtraLarge string `json:"extraLarge" jsonschema:"description=ExtraLarge is the largest cover image. If not available, Large will be used."`
			// Large is the second-largest cover image.
			Large string `json:"large" jsonschema:"description=Large is the second-largest cover image."`
			// Medium cover image. The smallest one.
			Medium string `json:"medium" jsonschema:"description=Medium cover image. The smallest one."`
			// Color average color of the cover image.
			Color string `json:"color" jsonschema:"description=Color average color of the cover image."`
		} `json:"cover" jsonschema:"description=Cover images of the manga"`
		// BannerImage is the banner image of the manga.
		BannerImage string `json:"bannerImage" jsonschema:"description=BannerImage is the banner image of the manga."`
		// Tags of the manga
		Tags []string `json:"tags" jsonschema:"description=Tags of the manga"`
		// Characters of the manga
		Characters []string `json:"characters" jsonschema:"description=Characters of the manga"`
		// Status of the manga
		Status string `json:"status" jsonschema:"enum=FINISHED,enum=RELEASING,enum=NOT_YET_RELEASED,enum=CANCELLED,enum=HIATUS"`
		// StartDate is the date when the manga started.
		StartDate date `json:"startDate" jsonschema:"description=StartDate is the date when the manga started."`
		// EndDate is the date when the manga ended.
		EndDate date `json:"endDate" jsonschema:"description=EndDate is the date when the manga ended."`
		// Synonyms other names of the manga.
		Synonyms []string `json:"synonyms" jsonschema:"description=Synonyms other names of the manga."`
		// Chapters is the amount of chapters the manga will have when completed.
		Chapters int `json:"chapters" jsonschema:"description=The amount of chapters the manga will have when completed."`
		// URLs external URLs of the manga.
		URLs []string `json:"urls" jsonschema:"description=External URLs of the manga."`
	} `json:"metadata"`
	// contains filtered or unexported fields
}

Manga is a manga from a source.

func (*Manga) BindWithAnilist

func (m *Manga) BindWithAnilist() error

func (*Manga) Dirname

func (m *Manga) Dirname() string

func (*Manga) DownloadCover

func (m *Manga) DownloadCover(overwrite bool, path string, progress func(string)) error

func (*Manga) GetCover

func (m *Manga) GetCover() (string, error)

func (*Manga) Path

func (m *Manga) Path(temp bool) (path string, err error)

func (*Manga) PopulateMetadata

func (m *Manga) PopulateMetadata(progress func(string)) error

func (*Manga) SeriesJSON

func (m *Manga) SeriesJSON() *SeriesJSON

func (*Manga) String

func (m *Manga) String() string

type Page

type Page struct {
	// URL of the page. Used to download the page.
	URL string `json:"url" jsonschema:"description=URL of the page. Used to download the image."`
	// Index of the page in the chapter.
	Index uint16 `json:"index" jsonschema:"description=Index of the page in the chapter."`
	// Extension of the page image.
	Extension string `json:"extension" jsonschema:"description=Extension of the page image."`
	// Size of the page in bytes
	Size uint64 `json:"-"`
	// Contents of the page
	Contents *bytes.Buffer `json:"-"`
	// Chapter that the page belongs to.
	Chapter *Chapter `json:"-"`
	// IsSplitted tell us if the page was cropped to multiple pieces
	IsSplitted bool `json:"is_cropped" jsonschema:"description=Was this page cropped."`
	// SplitPartIndex represent the index of the crop if the page was cropped
	SplitPartIndex uint16 `json:"crop_part_index" jsonschema:"description=Index of the crop if the image was cropped."`
}

Page represents a page in a chapter

func (*Page) Close

func (p *Page) Close() error

Close closes the page contents.

func (*Page) Download

func (p *Page) Download() error

Download Page contents.

func (*Page) Filename

func (p *Page) Filename() (filename string)

Filename generates a filename for the page.

func (*Page) Read

func (p *Page) Read(b []byte) (int, error)

Read reads from the page contents.

func (*Page) Source

func (p *Page) Source() Source

type SeriesJSON

type SeriesJSON struct {
	Metadata struct {
		Type                 string `json:"type"`
		Name                 string `json:"name"`
		DescriptionFormatted string `json:"description_formatted"`
		DescriptionText      string `json:"description_text"`
		Status               string `json:"status"`
		Year                 int    `json:"year"`
		ComicImage           string `json:"ComicImage"`
		Publisher            string `json:"publisher"`
		ComicID              int    `json:"comicId"`
		BookType             string `json:"booktype"`
		TotalIssues          int    `json:"total_issues"`
		PublicationRun       string `json:"publication_run"`
	} `json:"metadata"`
}

type Source

type Source interface {
	Name() string
	Search(query string) ([]*Manga, error)
	LoadChaptersOf(manga *Manga) error
	LoadPagesOf(chapter *Chapter) error
	ID() string
}

Source is the interface that all sources must implement.

Jump to

Keyboard shortcuts

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