models

package
v0.0.0-...-d10c4ce Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2025 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CastRelationship

func CastRelationship[T any](rel *Relationship) (out T, err error)

CastRelationship is a special helper function that uses JSON marshaling to transform a Relationship's attributes into another type.

This function should be used with care.

Types

type Author

type Author struct {
	Name string
	URI  string
}

Author is a single author/artist for a Manga, of which there may be several.

type Chapter

type Chapter struct {
	ID            uuid.UUID         `json:"id"`
	Attributes    ChapterAttributes `json:"attributes"`
	Relationships []Relationship    `json:"relationships"`
	// contains filtered or unexported fields
}

Chapter is a single chapter on MangaDex. Use FetchChapter to get one from the API.

func FetchChapter

func FetchChapter(
	ctx context.Context,
	id uuid.UUID,
	queryParams url.Values,
) (c Chapter, err error)

Fetch gets the chapter information the MangaDex API and returns the Chapter.

func (*Chapter) FetchImageURLs

func (c *Chapter) FetchImageURLs(ctx context.Context) (imgUrls []*url.URL, err error)

FetchImageURLs gets the list of image URLs that correspond to this Chapter. These URLs are not part of the normal MangaDex API, and are usually fetched from the Mangadex@Home servers via mangadex.network. This function uses the DataSaver and MDUploads global options

See also: https://api.mangadex.org/docs/04-chapter/retrieving-chapter/

func (*Chapter) FullTitle

func (c *Chapter) FullTitle() string

FullTitle builds and returns the full title of the chapter including the manga name, volume number, chapter number, and chapter title. This value is cached on the Chapter struct.

func (*Chapter) ImgURLs

func (c *Chapter) ImgURLs() []*url.URL

func (*Chapter) Manga

func (c *Chapter) Manga() *Manga

Manga finds and casts the Manga that this Chapter belongs to. This value is cached on the Chapter struct.

func (*Chapter) URL

func (c *Chapter) URL() string

type ChapterAttributes

type ChapterAttributes struct {
	Title              string    `json:"title"`
	Volume             string    `json:"volume"`
	Chapter            string    `json:"chapter"`
	Pages              int       `json:"pages"`
	TranslatedLanguage string    `json:"translatedLanguage"`
	CreatedAt          time.Time `json:"createdAt"`
	UpdatedAt          time.Time `json:"updatedAt"`
}

ChapterAttributes are all the field attributes for a chapter.

type Data

type Data[T any] struct {
	Result string `json:"result"`
	Data   T      `json:"data"`
	Limit  int    `json:"limit"`
	Offset int    `json:"offset"`
}

Data is a wrapping type that is used to parse most responses from the MangaDex API

type Manga

type Manga struct {
	ID            uuid.UUID       `json:"id"`
	Attributes    MangaAttributes `json:"attributes"`
	Relationships []Relationship  `json:"relationships"`
	// contains filtered or unexported fields
}

Manga is a single manga/comic series on MangaDex. Use FetchManga to get one from the API.

func FetchManga

func FetchManga(ctx context.Context, id uuid.UUID, queryParams url.Values) (m Manga, err error)

FetchManga gets the manga series information the MangaDex API and returns the Manga.

func SearchManga

func SearchManga(ctx context.Context, queryParams url.Values) (ms []Manga, err error)

SearchManga queries the MangaDex search endpoint and returns an array of Manga.

func (*Manga) Feed

func (m *Manga) Feed(ctx context.Context, queryParams url.Values) (cs []Chapter, err error)

Feed returns the chapter feed for a series as an array of Chapter. By default the it filters to the current language in shared.GlobalOptions and sorts the chapters in ascending order, filtering out empty chapters. This can be changed using the queryParams.

func (*Manga) RelData

func (m *Manga) RelData() (rd *RelData)

RelData returns the RelData for this manga. This value is cached on the Manga struct.

func (Manga) TrDesc

func (m Manga) TrDesc() string

TrDesc retuns the Manga's description translated using shared.Tr

func (Manga) TrTitle

func (m Manga) TrTitle() string

TrTitle returns the Manga's title translated using shared.Tr.

func (*Manga) URL

func (m *Manga) URL() string

type MangaAttributes

type MangaAttributes struct {
	Title            map[string]string   `json:"title"`
	AltTitles        []map[string]string `json:"altTitles"`
	Description      map[string]string   `json:"description"`
	OriginalLanguage string              `json:"originalLanguage"`
	Status           string              `json:"status"`
	Demographic      string              `json:"publicationDemographic"`
	CreatedAt        time.Time           `json:"createdAt"`
	UpdatedAt        time.Time           `json:"updatedAt"`
}

MangaAttributes are all the field attributes for a manga.

type RelData

type RelData struct {
	Authors  []Author
	CoverURL string
}

RelData is the parsed Relationship data for a Manga.

type Relationship

type Relationship struct {
	ID         string         `json:"id"`
	Type       string         `json:"type"`
	Attributes map[string]any `json:"attributes"`
}

Relationship represents a relation between one MangaDex data entity and another.

func (Relationship) URL

func (r Relationship) URL() url.URL

Jump to

Keyboard shortcuts

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