-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmangadata.go
144 lines (112 loc) · 3.41 KB
/
mangadata.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
package libmangal
import "fmt"
type MangaInfo struct {
// Title of the manga
Title string `json:"title"`
// AnilistSearch is the title of the manga
// that will be used for on Anilist.
//
// This is a separate field from the Title due to Title could
// be on any language, but Anilist only supports searching
// for english, native and romaji titles.
AnilistSearch string `json:"anilistSearch"`
// URL leading to manga page web page.
URL string `json:"url"`
// ID of the Manga. It must be unique withing its provider.
ID string `json:"id"`
// Cover is the cover image url.
Cover string `json:"cover"`
// Banner is the banner image url.
Banner string `json:"banner"`
}
type Manga interface {
fmt.Stringer
Info() MangaInfo
}
type MangaWithSeriesJSON interface {
Manga
// SeriesJSON will be used to write series.json file.
// If ok is false then mangal will try to search on Anilist for the
// relevant manga.
SeriesJSON() (SeriesJSON, error)
}
type VolumeInfo struct {
// Number of the volume. Must be greater than 0
Number int `json:"number"`
}
// Volume if a series is popular enough, its chapters
// are then collected and published into volumes,
// which usually feature a few chapters of the overall story.
// Most Manga series are long-running and can span multiple volumes.
//
// Mangal expects that each Manga must have at least one Volume
type Volume interface {
fmt.Stringer
Info() VolumeInfo
// Manga gets the Manga that this Volume is relevant to.
//
// Implementation should not make any external requests
// nor be computationally heavy.
Manga() Manga
}
type ChapterInfo struct {
// Title is the title of chapter
Title string `json:"title"`
// URL is the url leading to chapter web page.
URL string `json:"url"`
// Number of the chapter.
//
// Float type used in case of chapters that has numbers
// like this: 10.8 or 103.1.
Number float32 `json:"number"`
}
// Chapter is what Volume consists of. Each chapter is about 24–40 pages.
type Chapter interface {
fmt.Stringer
Info() ChapterInfo
// Volume gets the Volume that this Chapter is relevant to.
//
// Implementation should not make any external requests
// nor be computationally heavy.
Volume() Volume
}
type ChapterWithComicInfoXML interface {
Chapter
// ComicInfoXML will be used to write ComicInfo.xml file.
// If ok is false then mangal will try to search on Anilist for the
// relevant manga.
ComicInfoXML() (ComicInfoXML, error)
}
// Page is what Chapter consists of.
type Page interface {
fmt.Stringer
// GetExtension gets the image extension of this page.
// An extension must start with the dot.
//
// For example: .jpeg .png
GetExtension() string
// Chapter gets the Chapter that this Page is relevant to.
//
// Implementation should not make any external requests
// nor be computationally heavy.
Chapter() Chapter
}
// PageWithImage is a Page with downloaded image
type PageWithImage interface {
Page
// GetImage gets the image contents. This operation should not perform any extra requests.
// Implementation should expose this method only if the Page already contains image contents.
GetImage() []byte
// SetImage sets the image contents. This is used by DownloadOptions.ImageTransformer
SetImage(newImage []byte)
}
type pageWithImage struct {
Page
image []byte
}
func (p *pageWithImage) GetImage() []byte {
return p.image
}
func (p *pageWithImage) SetImage(newImage []byte) {
p.image = newImage
}