mangadexapi

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnknown          = errors.New("unknown error")
	ErrBadInput         = errors.New("bad input")
	ErrConnection       = errors.New("request is failed")
	ErrUnexpectedHeader = errors.New("unexpected response header value")
)

Functions

func GetChapterIdFromArgs added in v1.8.0

func GetChapterIdFromArgs(args []string) string

GetChapterIdFromArgs extracts the chapter ID from a list of arguments. It takes in a slice of strings representing the arguments and returns a string representing the chapter ID. If no valid chapter ID is found in the arguments, it returns an empty string.

func GetChapterIdFromUrl added in v1.8.0

func GetChapterIdFromUrl(link string) string

GetChapterIdFromUrl extracts the chapter ID from a MangaDex link. It takes a string link as input and returns a string representing the chapter ID.

func GetMangaIdFromArgs added in v1.8.0

func GetMangaIdFromArgs(args []string) string

GetMangaIdFromArgs extracts the manga ID from a list of arguments. It takes in a slice of strings representing the arguments and returns a string representing the manga ID. If no valid manga ID is found in the arguments, it returns an empty string.

func GetMangaIdFromUrl added in v1.0.1

func GetMangaIdFromUrl(link string) string

GetMangaIdFromUrl extracts the manga ID from a MangaDex link. It returns an empty string if the link is invalid.

Types

type Chapter

type Chapter struct {
	ID            string         `json:"id"`
	Type          string         `json:"type"`
	Attributes    ChapterAttr    `json:"attributes"`
	Relationships []Relationship `json:"relationships"`
}

func (Chapter) GetMangaId added in v1.8.0

func (c Chapter) GetMangaId() string

func (Chapter) Language added in v1.2.4

func (c Chapter) Language() string

func (Chapter) Number added in v1.2.0

func (c Chapter) Number() string

func (Chapter) PagesCount added in v1.2.0

func (c Chapter) PagesCount() int

func (Chapter) Title added in v1.2.0

func (c Chapter) Title() string

func (Chapter) UploadedBy added in v1.2.0

func (c Chapter) UploadedBy() string

func (Chapter) Volume added in v1.2.0

func (c Chapter) Volume() string

type ChapterAttr

type ChapterAttr struct {
	Volume             string    `json:"volume"`
	Chapter            string    `json:"chapter"`
	Title              string    `json:"title"`
	TranslatedLanguage string    `json:"translatedLanguage"`
	ExternalUrl        string    `json:"externalUrl"`
	PublishAt          time.Time `json:"publishAt"`
	ReadableAt         time.Time `json:"readableAt"`
	CreatedAt          time.Time `json:"createdAt"`
	UpdatedAt          time.Time `json:"updatedAt"`
	Pages              int       `json:"pages"`
	Version            int       `json:"version"`
}

type ChapterFullInfo added in v1.2.0

type ChapterFullInfo struct {
	DownloadBaseURL string
	HashId          string
	PngFiles        []string
	JpgFiles        []string
	// contains filtered or unexported fields
}

func (ChapterFullInfo) ImagesBaseUrl added in v1.2.0

func (c ChapterFullInfo) ImagesBaseUrl() string

func (ChapterFullInfo) ImagesCompressedFiles added in v1.2.0

func (c ChapterFullInfo) ImagesCompressedFiles() []string

func (ChapterFullInfo) ImagesFiles added in v1.2.0

func (c ChapterFullInfo) ImagesFiles() []string

func (ChapterFullInfo) Language added in v1.2.0

func (c ChapterFullInfo) Language() string

func (ChapterFullInfo) Number added in v1.2.0

func (c ChapterFullInfo) Number() string

func (ChapterFullInfo) PagesCount added in v1.2.4

func (c ChapterFullInfo) PagesCount() int

func (ChapterFullInfo) Title added in v1.2.0

func (c ChapterFullInfo) Title() string

func (ChapterFullInfo) Translator added in v1.2.0

func (c ChapterFullInfo) Translator() string

func (ChapterFullInfo) UploadedBy added in v1.2.0

func (c ChapterFullInfo) UploadedBy() string

func (ChapterFullInfo) Volume added in v1.2.0

func (c ChapterFullInfo) Volume() string

type ChapterMetaInfo added in v1.2.0

type ChapterMetaInfo struct {
	Hash      string   `json:"hash"`
	Data      []string `json:"data"`
	DataSaver []string `json:"dataSaver"`
}

type Clientapi added in v1.3.0

type Clientapi struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(userAgent string) Clientapi

NewClient creates a new client for interacting with the MangeDex API. userAgent: the User-Agent string to be used in the HTTP header. Returns a Clientapi struct with the configured Resty client.

func (Clientapi) DownloadImage added in v1.3.0

func (a Clientapi) DownloadImage(baseUrl, chapterHash, imageFilename string,
	isJpg bool) ([]byte, error)

DownloadImage downloads an image from the specified base URL, chapter hash, and image filename. Parameters: - baseUrl: the base URL of the image. - chapterHash: the hash of the chapter. - imageFilename: the filename of the image. - isJpg: a boolean indicating whether the image is in JPG format. Returns: - []byte: the downloaded image as a byte slice. - error: an error if the download fails.

func (Clientapi) Find added in v1.3.0

func (a Clientapi) Find(title string, limit, offset int, isDoujinshiAllow bool) (ResponseMangaList, error)

Find retrieves a list of manga based on the provided title, limit, offset, and isDoujinshiAllow flag. Parameters: - title: the title of the manga to search for - limit: the maximum number of manga to retrieve (max 96) - offset: the number of manga to skip before retrieving (int) - isDoujinshiAllow: a flag indicating whether doujinshi should be included in the search results (bool) Returns: - mangaList: a list of manga matching the search criteria (ResponseMangaList) - error: an error if the request fails or the response is not as expected (error)

func (Clientapi) GetAllFullChaptersInfo added in v1.10.0

func (a Clientapi) GetAllFullChaptersInfo(mangaId, language,
	translationGroup string) ([]ChapterFullInfo, error)

GetAllFullChaptersInfo retrieves the full information of all chapters of a manga. Duplicate chapters are not added in the result. Parameters: - mangaId: the ID of the manga. - language: the language of the chapters. - translationGroup: the translation group of the chapters. Returns: - []ChapterFullInfo: a list of full information of all chapters. - error: an error if there was a problem retrieving the information.

func (Clientapi) GetChapterImageList added in v1.3.0

func (a Clientapi) GetChapterImageList(chapterId string) (ResponseChapterImages, error)

GetChapterImageList retrieves a list of images for a given chapter. Parameters: - chapterId: the ID of the chapter Returns: - ResponseChapterImages: a list of images - error: an error if the request fails or the response is not as expected

func (Clientapi) GetChapterImagesInFullInfo added in v1.8.0

func (a Clientapi) GetChapterImagesInFullInfo(chap Chapter) (ChapterFullInfo, error)

GetChapterImagesInFullInfo retrieves the full information of a chapter and chapter images. Parameters: - chap: The chapter for which to retrieve the images. Returns: - ChapterFullInfo: The full information of the chapter's images. - error: An error if the request fails or the response is an error.

func (Clientapi) GetChapterInfo added in v1.8.0

func (a Clientapi) GetChapterInfo(chapterId string) (ResponseChapter, error)

GetChapterInfo retrieves the information of a chapter with the given chapterId.

func (Clientapi) GetChaptersList added in v1.3.0

func (a Clientapi) GetChaptersList(limit, offset int, mangaId, language string) (ResponseChapterList, error)

GetChaptersList retrieves a list of chapters for a given manga, limit, offset, and language. Parameters: - limit: the maximum number of chapters to retrieve - offset: the number of chapters to skip before retrieving - mangaId: the ID of the manga - language: the language of the chapters Returns: - ResponseChapterList: a list of chapters (ResponseChapterList) - error: an error if the request fails or the response is not as expected (error)

func (Clientapi) GetFullChaptersInfo added in v1.3.0

func (a Clientapi) GetFullChaptersInfo(mangaId, language, translationGroup string,
	lowestChapter, highestChapter int) ([]ChapterFullInfo, error)

GetFullChaptersInfo retrieves the full information of all chapters within a given range for a specific manga. Parameters: - mangaId: the ID of the manga. - language: the language of the chapters. - translationGroup: the translation group of the chapters. - lowestChapter: the lowest chapter number. - highestChapter: the highest chapter number. Returns: - []ChapterFullInfo: a slice of ChapterFullInfo structs containing the full information of the chapters. - error: an error if there was a problem retrieving the information.

func (Clientapi) GetLastChapterFullInfo added in v1.9.0

func (a Clientapi) GetLastChapterFullInfo(mangaId, language,
	translationGroup string) (ChapterFullInfo, error)

GetLastChapterFullInfo retrieves the full information of the last chapter of a manga. Parameters: - mangaId: the ID of the manga. - language: the language of the chapters. - translationGroup: the translation group of the chapters. Returns: - ChapterFullInfo: the full information of the last chapter. - error: an error if there was a problem retrieving the information.

func (Clientapi) GetMangaInfo added in v1.3.0

func (a Clientapi) GetMangaInfo(mangaId string) (MangaInfoResponse, error)

GetMangaInfo retrieves the information of a manga with the given mangaId.

func (Clientapi) Ping added in v1.3.0

func (a Clientapi) Ping() bool

Ping checks the health of the API by sending a GET request to the health_path endpoint. It returns a boolean value based on the status code and error response.

type ErrorDetail

type ErrorDetail struct {
	ID      string `json:"id"`
	Status  int    `json:"status"`
	Title   string `json:"title"`
	Detail  string `json:"detail"`
	Context string `json:"context"`
}

type ErrorResponse

type ErrorResponse struct {
	Result string        `json:"result"`
	Errors []ErrorDetail `json:"errors"`
}

func (*ErrorResponse) Error

func (e *ErrorResponse) Error() string

type MangaAttrib

type MangaAttrib struct {
	Title                          map[string]string   `json:"title"`
	AltTitles                      []map[string]string `json:"altTitles"`
	Description                    map[string]string   `json:"description"`
	IsLocked                       bool                `json:"isLocked"`
	Links                          map[string]string   `json:"links"`
	OriginalLanguage               string              `json:"originalLanguage"`
	LastVolume                     string              `json:"lastVolume"`
	LastChapter                    string              `json:"lastChapter"`
	PublicationDemographic         string              `json:"publicationDemographic"`
	Status                         string              `json:"status"`
	Year                           int                 `json:"year"`
	ContentRating                  string              `json:"contentRating"`
	Tags                           []MangaTag          `json:"tags"`
	State                          string              `json:"state"`
	ChapterNumbersResetOnNewVolume bool                `json:"chapterNumbersResetOnNewVolume"`
	CreatedAt                      time.Time           `json:"createdAt"`
	UpdatedAt                      time.Time           `json:"updatedAt"`
	Version                        int                 `json:"version"`
	AvailableTranslatedLanguages   []string            `json:"availableTranslatedLanguages"`
	LatestUploadedChapter          string              `json:"latestUploadedChapter"`
}

type MangaInfo

type MangaInfo struct {
	ID            string         `json:"id"`
	Type          string         `json:"type"`
	Attributes    MangaAttrib    `json:"attributes"`
	Relationships []Relationship `json:"relationships"`
}

func (MangaInfo) AltTitles added in v1.2.4

func (mi MangaInfo) AltTitles() string

func (MangaInfo) Artists added in v1.2.4

func (mi MangaInfo) Artists() string

func (MangaInfo) ArtistsArr added in v1.2.4

func (mi MangaInfo) ArtistsArr() []string

func (MangaInfo) Authors added in v1.2.4

func (mi MangaInfo) Authors() string

func (MangaInfo) AuthorsArr added in v1.2.4

func (mi MangaInfo) AuthorsArr() []string

func (MangaInfo) Description added in v1.2.4

func (mi MangaInfo) Description(language string) string
func (mi MangaInfo) Links() string

func (MangaInfo) LinksArr added in v1.5.1

func (mi MangaInfo) LinksArr() []string

func (MangaInfo) OriginalLanguage added in v1.2.4

func (mi MangaInfo) OriginalLanguage() string

func (MangaInfo) Publisher added in v1.2.4

func (mi MangaInfo) Publisher() string

func (MangaInfo) Status added in v1.2.4

func (mi MangaInfo) Status() string

func (MangaInfo) Tags added in v1.2.4

func (mi MangaInfo) Tags() string

func (MangaInfo) TagsArr added in v1.2.4

func (mi MangaInfo) TagsArr() []string

func (MangaInfo) Title added in v1.2.4

func (mi MangaInfo) Title(language string) string

func (MangaInfo) TranslatedLanguages added in v1.2.4

func (mi MangaInfo) TranslatedLanguages() []string

func (MangaInfo) Year added in v1.2.4

func (mi MangaInfo) Year() int

type MangaInfoResponse

type MangaInfoResponse struct {
	Result   string    `json:"result"`
	Response string    `json:"response"`
	Data     MangaInfo `json:"data"`
}

func (MangaInfoResponse) MangaInfo added in v1.2.4

func (m MangaInfoResponse) MangaInfo() MangaInfo

type MangaTag

type MangaTag struct {
	ID         string `json:"id"`
	Type       string `json:"type"`
	Attributes struct {
		Name        map[string]string `json:"name"`
		Description struct{}          `json:"description"`
		Group       string            `json:"group"`
		Version     int               `json:"version"`
	} `json:"attributes"`
	Relationships []interface{} `json:"relationships"`
}

type RelAttribute

type RelAttribute struct {
	Name        string `json:"name"`
	Username    string `json:"username"`
	Description string `json:"description"`
}

type Relationship

type Relationship struct {
	ID         string       `json:"id"`
	Type       string       `json:"type"`
	Related    string       `json:"related,omitempty"`
	Attributes RelAttribute `json:"attributes"`
}

type ResponseChapter added in v1.8.0

type ResponseChapter struct {
	Result   string  `json:"result"`
	Response string  `json:"response"`
	Data     Chapter `json:"data"`
}

func (ResponseChapter) GetChapterInfo added in v1.8.0

func (r ResponseChapter) GetChapterInfo() Chapter

type ResponseChapterImages

type ResponseChapterImages struct {
	Result          string          `json:"result"`
	BaseURL         string          `json:"baseUrl"`
	ChapterMetaInfo ChapterMetaInfo `json:"chapter"`
}

type ResponseChapterList

type ResponseChapterList struct {
	Result   string    `json:"result"`
	Response string    `json:"response"`
	Data     []Chapter `json:"data"`
	Limit    int       `json:"limit"`
	Offset   int       `json:"offset"`
	Total    int       `json:"total"`
}

func (ResponseChapterList) GetAllChapters added in v1.10.0

func (l ResponseChapterList) GetAllChapters(transgp string) []Chapter

func (ResponseChapterList) GetChapters added in v1.2.0

func (l ResponseChapterList) GetChapters(lowest, highest int, transgp string) ([]Chapter, int)

type ResponseMangaList

type ResponseMangaList struct {
	Result   string      `json:"result"`
	Response string      `json:"response"`
	Data     []MangaInfo `json:"data"`
	Limit    int         `json:"limit"`
	Offset   int         `json:"offset"`
	Total    int         `json:"total"`
}

func (ResponseMangaList) List added in v1.2.4

func (ml ResponseMangaList) List() []MangaInfo

Jump to

Keyboard shortcuts

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