mangadex

package module
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2020 License: MIT Imports: 12 Imported by: 0

README

mangadex-go

Go Report Card GoDoc License GitHub go.mod Go version GitHub tag (latest SemVer)

Yet another unofficial MangaDex API, built using the JSON API and web parsing.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BaseURL = "https://mangadex.org"

BaseURL host base url.

Functions

This section is empty.

Types

type Agent

type Agent struct {
	SessionID,
	PersistentID string
	SessionExpires time.Time
	User           User
}

Agent represents user and session information.

func NewAgent

func NewAgent() *Agent

NewAgent creates a new instance of agent.

func (*Agent) LoadSession

func (a *Agent) LoadSession(path string) error

LoadSession loads session from a file. It returns errNoSessionCache when the specified sessionPath doesn't exists.

func (*Agent) Login

func (a *Agent) Login(username, password string, remember bool) error

Login logins to mangadex and retrieves SessionID and PersistentID. It returns errIncorrectUsernameOrPassword when the specified username or password is invalid.

func (*Agent) SaveSession

func (a *Agent) SaveSession(path string) error

SaveSession saves session to a file. It returns errEmptySessionID when SessionID is empty.

func (*Agent) ValidateSession

func (a *Agent) ValidateSession() error

ValidateSession validates an existing SessionID. It returns errEmptySessionID when SessionID is empty, and returns errInvalidOrExpireSession when SessionID is invalid or expired.

type Chapter

type Chapter struct {
	ID,
	Chapter,
	Comments,
	MangaID,
	Volume,
	Timestamp int
	Title,
	Language,
	Hash,
	Server string
	Pages  []string
	Groups []GroupPartial
}

Chapter represents full information of a chapter.

func GetChapter

func GetChapter(id int) (*Chapter, error)

GetChapter retrieves all available information and pages of a chapter by its ID.

type ChapterPartial

type ChapterPartial struct {
	ID,
	Chapter,
	Volume,
	Timestamp int
	Title,
	Language string
	Groups []GroupPartial
}

ChapterPartial represents partial information of a chapter.

type Demographic

type Demographic int
const (
	DemographicShounen Demographic = 1 + iota
	DemographicShoujo
	DemographicSeinen
	DemographicJosei
)

type Follows

type Follows struct {
	Manga []MangaPartial
	CurrentPage,
	ResultsCount int
	// contains filtered or unexported fields
}

func GetFollows

func GetFollows(a *Agent) (*Follows, error)

GetFollows retrieves all available followed manga

func (*Follows) Next

func (f *Follows) Next() (*Follows, error)

Next retrieves next page of search result. It returns nil when next page is unavailable.

type Genre

type Genre int
const (
	Genre4Koma            Genre = 1
	GenreAction           Genre = 2
	GenreAdventure        Genre = 3
	GenreAwardWinning     Genre = 4
	GenreComedy           Genre = 5
	GenreCooking          Genre = 6
	GenreDoujinshi        Genre = 7
	GenreDrama            Genre = 8
	GenreEcchi            Genre = 9
	GenreFantasy          Genre = 10
	GenreGyaru            Genre = 11
	GenreHarem            Genre = 12
	GenreHistorical       Genre = 13
	GenreHorror           Genre = 14
	GenreMartialArts      Genre = 16
	GenreMecha            Genre = 17
	GenreMedical          Genre = 18
	GenreMusic            Genre = 19
	GenreMystery          Genre = 20
	GenreOneshot          Genre = 21
	GenrePsychological    Genre = 22
	GenreRomance          Genre = 23
	GenreSchoolLife       Genre = 24
	GenreSciFi            Genre = 25
	GenreShoujoAi         Genre = 28
	GenreShounenAi        Genre = 30
	GenreSliceofLife      Genre = 31
	GenreSmut             Genre = 32
	GenreSports           Genre = 33
	GenreSupernatural     Genre = 34
	GenreTragedy          Genre = 35
	GenreLongStrip        Genre = 36
	GenreYaoi             Genre = 37
	GenreYuri             Genre = 38
	GenreVideoGames       Genre = 40
	GenreIsekai           Genre = 41
	GenreAdaptation       Genre = 42
	GenreAnthology        Genre = 43
	GenreWebComic         Genre = 44
	GenreFullColor        Genre = 45
	GenreUserCreated      Genre = 46
	GenreOfficialColored  Genre = 47
	GenreFanColored       Genre = 48
	GenreGore             Genre = 49
	GenreSexualViolence   Genre = 50
	GenreCrime            Genre = 51
	GenreMagicalGirls     Genre = 52
	GenrePhilosophical    Genre = 53
	GenreSuperhero        Genre = 54
	GenreThriller         Genre = 55
	GenreWuxia            Genre = 56
	GenreAliens           Genre = 57
	GenreAnimals          Genre = 58
	GenreCrossdressing    Genre = 59
	GenreDemons           Genre = 60
	GenreDelinquents      Genre = 61
	GenreGenderswap       Genre = 62
	GenreGhosts           Genre = 63
	GenreMonsterGirls     Genre = 64
	GenreLoli             Genre = 65
	GenreMagic            Genre = 66
	GenreMilitary         Genre = 67
	GenreMonsters         Genre = 68
	GenreNinja            Genre = 69
	GenreOfficeWorkers    Genre = 70
	GenrePolice           Genre = 71
	GenrePostApocalyptic  Genre = 72
	GenreReincarnation    Genre = 73
	GenreReverseHarem     Genre = 74
	GenreSamurai          Genre = 75
	GenreShota            Genre = 76
	GenreSurvival         Genre = 77
	GenreTimeTravel       Genre = 78
	GenreVampires         Genre = 79
	GenreTraditionalGames Genre = 80
	GenreVirtualReality   Genre = 81
	GenreZombies          Genre = 82
	GenreIncest           Genre = 83
)

type Group

type Group struct {
	ID,
	LikeCount int
	Name,
	AlternativeName,
	Cover,
	Language,
	Description,
	RSS string
	Statistics struct {
		Views,
		Follows,
		Chapters,
		Comments int
	}
	Links             []string
	Leader            UserPartial
	Members           []UserPartial
	UploadRestriction UploadRestriction
	Delay             string
}

Group represents full information of a group.

func GetGroup

func GetGroup(id int) (*Group, error)

GetGroup retrieves all available information of a group by its ID.

type GroupPartial

type GroupPartial struct {
	ID   int
	Name string
}

GroupPartial represents partial information of a group.

type GroupSearch

type GroupSearch struct {
	Groups []GroupPartial
	CurrentPage,
	ResultsCount int
	// contains filtered or unexported fields
}

GroupSearch represents search information and partial information of all available groups.

func SearchGroup

func SearchGroup(name string) (*GroupSearch, error)

SearchGroup retrieves group(s) by name.

func (*GroupSearch) Next

func (s *GroupSearch) Next() (*GroupSearch, error)

Next retrieves next page of search result. It returns nil when next page is unavailable.

type Home

type Home struct {
	Latest,
	Follows,
	Top6H,
	Top24H,
	Top7D,
	TopFollows,
	TopRating []MangaPartial
}

Home represents all available manga (Latest, Follows, Top Chapters, Top Manga) on the homepage.

func GetHome

func GetHome() (*Home, error)

GetHome retrieves all available manga (Latest, Follows, Top Chapters, Top Manga) on the homepage.

type Language

type Language string
const (
	LanguageArabic        Language = "SA"
	LanguageBengali       Language = "BD"
	LanguageBulgarian     Language = "BG"
	LanguageBurmese       Language = "MM"
	LanguageCatalan       Language = "CT"
	LanguageChineseSimp   Language = "CN"
	LanguageChineseTrad   Language = "HK"
	LanguageCzech         Language = "CZ"
	LanguageDanish        Language = "DK"
	LanguageDutch         Language = "NL"
	LanguageEnglish       Language = "GB"
	LanguageFilipino      Language = "PH"
	LanguageFinnish       Language = "FI"
	LanguageFrench        Language = "FR"
	LanguageGerman        Language = "DE"
	LanguageGreek         Language = "GR"
	LanguageHungarian     Language = "HU"
	LanguageIndonesian    Language = "ID"
	LanguageItalian       Language = "IT"
	LanguageJapanese      Language = "JP"
	LanguageKorean        Language = "KR"
	LanguageLithuanian    Language = "LT"
	LanguageMalay         Language = "MY"
	LanguageMongolian     Language = "MN"
	LanguagePersian       Language = "IR"
	LanguagePolish        Language = "PL"
	LanguagePortugueseBR  Language = "BR"
	LanguagePortuguesePT  Language = "PT"
	LanguageRomanian      Language = "RO"
	LanguageRussian       Language = "RU"
	LanguageSerboCroatian Language = "RS"
	LanguageSpanishEs     Language = "ES"
	LanguageSpanishLATAM  Language = "MX"
	LanguageSwedish       Language = "SE"
	LanguageThai          Language = "TH"
	LanguageTurkish       Language = "TR"
	LanguageUkrainian     Language = "UA"
	LanguageVietnamese    Language = "VN"
)

type ListingOrder

type ListingOrder int
const (
	ListingOrderLastUpdatedAsc ListingOrder = iota
	ListingOrderLastUpdatedDesc
	ListingOrderTitleAsc
	ListingOrderTitleDesc
	ListingOrderCommentsAsc
	ListingOrderCommentsDesc
	ListingOrderRatingAsc
	ListingOrderRatingDesc
	ListingOrderViewsAsc
	ListingOrderViewsDesc
	ListingOrderFollowsAsc
	ListingOrderFollowsDesc
)

type Manga

type Manga struct {
	ID int
	Title,
	Origin,
	Cover string
	AlternativeTitles,
	Authors,
	Artists,
	Demographics,
	Contents,
	Formats,
	Genres,
	Themes []string
	Hentai bool
	Rating struct {
		Bayesian float32
		Mean     float32
		Users    int
	}
	Status     string
	Statistics struct {
		Views,
		Follows,
		Chapters,
		Comments int
	}
	Description string
	Related     []MangaRelated
	OfficialLinks,
	RetailLinks,
	InformationLinks []MangaExternalLink
	Chapters []ChapterPartial
	// contains filtered or unexported fields
}

Manga represents full information and all available chapters of a manga.

func GetManga

func GetManga(id int) (*Manga, error)

GetManga retrieves all available information and chapters of a manga by its ID.

func GetRandomManga

func GetRandomManga() (*Manga, error)

GetRandomManga retrieves random manga.

func (*Manga) GetCovers

func (m *Manga) GetCovers() ([]string, error)

GetCovers retrieves all available covers of a manga.

type MangaExternalLink struct {
	Name,
	URL string
}

MangaExternalLink represents information of external link.

type MangaPartial

type MangaPartial struct {
	ID    int
	Title string
}

MangaPartial represents partial information of a manga.

func GetFeatured

func GetFeatured() ([]MangaPartial, error)

Retrieves all available featured manga

type MangaRelated

type MangaRelated struct {
	Title,
	Type string
	ID int
}

MangaRelated represents information of related manga.

type MangaSearch

type MangaSearch struct {
	Manga []MangaPartial
	CurrentPage,
	ResultsCount int
	// contains filtered or unexported fields
}

MangaSearch represents search information and partial information of all available manga.

func SearchManga

func SearchManga(a *Agent, q *MangaSearchQuery) (*MangaSearch, error)

SearchManga retrieves manga(s) by query.

func (*MangaSearch) Next

func (s *MangaSearch) Next() (*MangaSearch, error)

Next retrieves next page of search result. It returns nil when next page is unavailable.

type MangaSearchQuery

type MangaSearchQuery struct {
	Title,
	Author,
	Artist string
	Origin           Origin
	Demographics     []Demographic
	PublishStatuses  []PublishStatus
	ExcludeTags      []Genre
	IncludeTags      []Genre
	TagExclusionMode TagExclusionMode
	TagInclusionMode TagInclusionMode
	ListingOrder     ListingOrder
}

MangaSearchQuery represents search queries.

type Origin

type Origin int
const (
	OriginEnglish      Origin = 1
	OriginJapanese     Origin = 2
	OriginPolish       Origin = 3
	OriginGerman       Origin = 8
	OriginFrench       Origin = 10
	OriginVietnamese   Origin = 12
	OriginChinese      Origin = 21
	OriginIndonesian   Origin = 27
	OriginKorean       Origin = 28
	OriginSpanishLATAM Origin = 29
	OriginThai         Origin = 32
	OriginPhilippines  Origin = 34
	OriginHongkong     Origin = 35
)

func (Origin) Code

func (v Origin) Code() string

func (Origin) Full

func (v Origin) Full() string

type PublishStatus

type PublishStatus int
const (
	PublishStatusOngoing PublishStatus = 1 + iota
	PublishStatusCompleted
	PublishStatusCancelled
	PublishStatusHiatus
)

type TagExclusionMode

type TagExclusionMode int
const (
	TagExclusionModeAny TagExclusionMode = iota
	TagExclusionModeAll
)

type TagInclusionMode

type TagInclusionMode int
const (
	TagInclusionModeAll TagInclusionMode = iota
	TagInclusionModeAny
)

type UploadRestriction

type UploadRestriction string
const (
	UploadRestrictionMembersOnly UploadRestriction = "members"
	UploadRestrictionAll         UploadRestriction = "everyone"
)

type User

type User struct {
	ID int
	Username,
	Language,
	Avatar string
}

User represents information of a user.

type UserPartial

type UserPartial struct {
	ID   int
	Name string
}

UserPartial represents partial information of a user.

Directories

Path Synopsis
internal
app

Jump to

Keyboard shortcuts

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