2023-03-03 14:37:16 +01:00
|
|
|
package nuapi
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
2023-03-03 14:50:27 +01:00
|
|
|
type NovelID = string
|
|
|
|
type ChapterID = string
|
|
|
|
type ReadingListID = string
|
|
|
|
type GroupID = string
|
2023-03-03 14:37:16 +01:00
|
|
|
|
|
|
|
type ReadingList struct {
|
|
|
|
ID ReadingListID `json:"id"`
|
|
|
|
Entries []ReadingListEntry `json:"entries"`
|
|
|
|
}
|
|
|
|
|
2023-03-03 15:08:21 +01:00
|
|
|
func (l ReadingList) String() string {
|
|
|
|
data, _ := json.MarshalIndent(l, "", "\t")
|
|
|
|
return string(data)
|
|
|
|
}
|
|
|
|
|
2023-03-03 14:37:16 +01:00
|
|
|
type ReadingListEntry struct {
|
|
|
|
Novel NovelEntry `json:"novel"`
|
|
|
|
CurrentChapter ReadingListChapterEntry `json:"current_chapter"`
|
|
|
|
LatestChapter ReadingListChapterEntry `json:"latest_chapter"`
|
|
|
|
}
|
|
|
|
|
2023-03-03 15:08:21 +01:00
|
|
|
func (e ReadingListEntry) String() string {
|
|
|
|
data, _ := json.MarshalIndent(e, "", "\t")
|
|
|
|
return string(data)
|
|
|
|
}
|
|
|
|
|
2023-03-03 14:37:16 +01:00
|
|
|
func (e ReadingListEntry) NewChapterAvailable() bool {
|
|
|
|
return e.CurrentChapter.ID != e.LatestChapter.ID
|
|
|
|
}
|
|
|
|
|
|
|
|
type ReadingListChapterEntry struct {
|
|
|
|
NovelID NovelID `json:"novel_id"`
|
|
|
|
ID ChapterID `json:"id"`
|
|
|
|
Link string `json:"link"`
|
|
|
|
}
|
|
|
|
|
2023-03-03 15:08:21 +01:00
|
|
|
func (e ReadingListChapterEntry) String() string {
|
|
|
|
data, _ := json.MarshalIndent(e, "", "\t")
|
|
|
|
return string(data)
|
|
|
|
}
|
|
|
|
|
2023-03-03 14:37:16 +01:00
|
|
|
type NovelEntry struct {
|
|
|
|
NovelID NovelID `json:"id"`
|
|
|
|
Name string `json:"name"`
|
|
|
|
}
|
|
|
|
|
2023-03-03 15:08:21 +01:00
|
|
|
func (e NovelEntry) String() string {
|
|
|
|
data, _ := json.MarshalIndent(e, "", "\t")
|
|
|
|
return string(data)
|
|
|
|
}
|
|
|
|
|
2023-03-03 14:37:16 +01:00
|
|
|
type Novel struct {
|
|
|
|
ID NovelID `json:"id"`
|
|
|
|
Name string `json:"name"`
|
|
|
|
AssociatedNames []string `json:"associated_names"`
|
|
|
|
Description string `json:"description"`
|
|
|
|
Cover string `json:"cover"`
|
|
|
|
Type NovelType `json:"type"`
|
|
|
|
OriginalLanguage Language `json:"original_language"`
|
|
|
|
Genres []GenreID `json:"genres"`
|
|
|
|
Tags []TagID `json:"tags"`
|
|
|
|
}
|
|
|
|
|
2023-03-03 15:08:21 +01:00
|
|
|
func (n Novel) String() string {
|
|
|
|
data, _ := json.MarshalIndent(n, "", "\t")
|
|
|
|
return string(data)
|
|
|
|
}
|
|
|
|
|
2023-03-03 14:37:16 +01:00
|
|
|
type NovelType string
|
|
|
|
|
|
|
|
const (
|
|
|
|
TypeLightNovel NovelType = "Light Novel"
|
|
|
|
TypePublishedNovel NovelType = "Published Novel"
|
|
|
|
TypeWebNovel NovelType = "Web Novel"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Language string
|
|
|
|
|
|
|
|
const (
|
|
|
|
LanguageJapanese Language = "jp"
|
|
|
|
LanguageChinese Language = "cn"
|
|
|
|
LanguageMalaysian Language = "my"
|
|
|
|
LanguageFilipino Language = "fil"
|
|
|
|
LanguageKhmer Language = "khm"
|
|
|
|
LanguageThai Language = "th"
|
|
|
|
LanguageIndonesian Language = "id"
|
|
|
|
LanguageKorean Language = "kr"
|
|
|
|
LanguageVietnamese Language = "vn"
|
|
|
|
)
|
|
|
|
|
|
|
|
type NovelChapterEntry struct {
|
|
|
|
ID ChapterID `json:"id"`
|
|
|
|
Link string `json:"link"`
|
|
|
|
NovelID NovelID `json:"novel_id"`
|
|
|
|
Date time.Time `json:"date"`
|
|
|
|
Group GroupID `json:"group"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func (nce NovelChapterEntry) String() string {
|
|
|
|
data, _ := json.MarshalIndent(nce, "", "\t")
|
|
|
|
return string(data)
|
|
|
|
}
|