models

package
v0.0.0-...-b34fe98 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2023 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BSCache *cache.Cache = cache.New(0, 0)
View Source
var Shelf = &BookShelf{}

Functions

func InitBS

func InitBS(fileName string)

func InitShelf

func InitShelf(fileName string)

func SortSearchOutput

func SortSearchOutput(so SearchOutput) []string

Types

type Book

type Book struct {
	Tag          string        `json:"tag"`
	Origin       string        `json:"origin"`
	Name         string        `json:"name"`
	Author       string        `json:"author"`
	BookmarkList []interface{} `json:"bookmarkList"`
	ChapterURL   string        `json:"chapterUrl"`
	// BookURL        string            `json:"book_url"`
	CoverURL         string            `json:"coverUrl"`
	Kind             string            `json:"kind"`
	LastChapter      string            `json:"lastChapter"`
	FinalRefreshDate UnixTime          `json:"finalRefreshData"` // typo here
	NoteURL          string            `json:"noteUrl"`
	Introduce        string            `json:"introduce"`
	ChapterList      []*Chapter        `json:"chapterList"`
	BookSourceInst   *BookSource       `json:"-"`
	Page             *goquery.Document `json:"-"`
}

func (*Book) DownloadCover

func (b *Book) DownloadCover(coverPath string) error

func (*Book) FromCache

func (b *Book) FromCache(bookPath string) error

TODO not finished yet

func (*Book) FromURL

func (b *Book) FromURL(bookURL string) error

func (*Book) GetAuthor

func (b *Book) GetAuthor() string

func (*Book) GetBookSource

func (b *Book) GetBookSource() *BookSource

func (*Book) GetChapterList

func (b *Book) GetChapterList(offset, limit int) []*Chapter

func (*Book) GetChapterURL

func (b *Book) GetChapterURL() string

func (*Book) GetCoverURL

func (b *Book) GetCoverURL() string

func (*Book) GetIntroduce

func (b *Book) GetIntroduce() string

func (*Book) GetName

func (b *Book) GetName() string

func (*Book) GetOrigin

func (b *Book) GetOrigin() string

func (Book) String

func (b Book) String() string

func (*Book) UpdateChapterList

func (b *Book) UpdateChapterList(startFrom int) error

type BookShelf

type BookShelf struct {
	FilePath string
	Books    Items
}

func (*BookShelf) Save

func (b *BookShelf) Save() error

func (*BookShelf) Sort

func (b *BookShelf) Sort()

type BookSource

type BookSource struct {
	BookSourceGroup       string `json:"bookSourceGroup"`
	BookSourceName        string `json:"bookSourceName"`
	BookSourceURL         string `json:"bookSourceUrl"`
	CheckURL              string `json:"checkUrl"`
	Enable                bool   `json:"enable"`
	HTTPUserAgent         string `json:"httpUserAgent"`
	RuleBookAuthor        string `json:"ruleBookAuthor"`
	RuleBookContent       string `json:"ruleBookContent"`
	RuleBookName          string `json:"ruleBookName"`
	RuleChapterList       string `json:"ruleChapterList"`
	RuleChapterName       string `json:"ruleChapterName"`
	RuleChapterURL        string `json:"ruleChapterUrl"`
	RuleChapterURLNext    string `json:"ruleChapterUrlNext"`
	RuleContentURL        string `json:"ruleContentUrl"`
	RuleCoverURL          string `json:"ruleCoverUrl"`
	RuleFindURL           string `json:"ruleFindUrl"`
	RuleIntroduce         string `json:"ruleIntroduce"`
	RuleSearchAuthor      string `json:"ruleSearchAuthor"`
	RuleSearchCoverURL    string `json:"ruleSearchCoverUrl"`
	RuleSearchKind        string `json:"ruleSearchKind"`
	RuleSearchLastChapter string `json:"ruleSearchLastChapter"`
	RuleSearchList        string `json:"ruleSearchList"`
	RuleSearchName        string `json:"ruleSearchName"`
	RuleSearchNoteURL     string `json:"ruleSearchNoteUrl"`
	RuleSearchURL         string `json:"ruleSearchUrl"`
	SerialNumber          int    `json:"serialNumber"`
	Weight                int    `json:"weight"`
}

func GetBookSourceByURL

func GetBookSourceByURL(url string) *BookSource

func (*BookSource) SearchBook

func (b *BookSource) SearchBook(title string) []*Book

例:http://www.gxwztv.com/search.htm?keyword=searchKey&pn=searchPage-1 - ?为get @为post - searchKey为关键字标识,运行时会替换为搜索关键字, - searchPage,searchPage-1为搜索页数,从0开始的用searchPage-1, - page规则还可以写成 {index(第一页), indexSecond(第二页), indexThird(第三页), index-searchPage+1 或 index-searchPage-1 或 index-searchPage} - 要添加转码编码在最后加 |char=gbk - |char=escape 会模拟js escape方法进行编码 如果搜索结果可能会跳到简介页请填写简介页url正则

func (BookSource) String

func (bs BookSource) String() string

type Chapter

type Chapter struct {
	BookSourceSite string            `json:"source"`
	BookSourceInst *BookSource       `json:"-"`
	Content        string            `json:"content"`
	ChapterTitle   string            `json:"title"`
	Read           bool              `json:"is_read"`
	ChapterURL     string            `json:"url"`
	Index          int               `json:"index"`
	BelongToBook   *Book             `json:"-"`
	Page           *goquery.Document `json:"-"`
}

func (*Chapter) FromURL

func (c *Chapter) FromURL(chapterURL string) error

func (*Chapter) GetBook

func (c *Chapter) GetBook() *Book

func (*Chapter) GetBookSource

func (c *Chapter) GetBookSource() *BookSource

func (*Chapter) GetContent

func (c *Chapter) GetContent() string

func (*Chapter) GetIndex

func (c *Chapter) GetIndex() int

func (*Chapter) GetTitle

func (c *Chapter) GetTitle() string

func (Chapter) String

func (c Chapter) String() string

type Items

type Items []*ShelfItem

func (Items) Len

func (s Items) Len() int

func (Items) Less

func (s Items) Less(i, j int) bool

实现sort的接口,用来给书架排序,最后阅读时间近的排前面

func (Items) Swap

func (s Items) Swap(i, j int)

type SearchOutput

type SearchOutput map[string][]*Book

func SearchBooks

func SearchBooks(title string) SearchOutput

type SearchResult

type SearchResult struct {
	BookSourceSite string `json:"source"`
	BookTitle      string `json:"name"`
	Author         string `json:"author"`
	BookURL        string `json:"book_url"`
	CoverURL       string `json:"cover_url"`
	Kind           string `json:"kind"`
	LastChapter    string `json:"last_chapter"`
	NoteURL        string `json:"note_url"`
}

type ShelfItem

type ShelfItem struct {
	AllowUpdate      bool     `json:"allowUpdate"`      // 是否允许更新
	BookInfoBean     *Book    `json:"bookInfoBean"`     // 书籍信息
	ChapterListSize  int      `json:"chapterListSize"`  // 章节数
	DurChapter       int      `json:"durChapter"`       // 在读章节index
	DurChapterName   string   `json:"durChapterName"`   // 在读章节名字
	DurChapterPage   int      `json:"durChapterPage"`   // 在读章节页数
	FinalDate        UnixTime `json:"finalDate"`        // 最后阅读时间?
	FinalRefreshDate UnixTime `json:"finalRefreshData"` // 最后更新时间 "阅读"有typo,这里应该是 finalRefreshDate
	Group            int      `json:"group"`            // 分组
	HasUpdate        bool     `json:"hasUpdate"`
	IsLoading        bool     `json:"isLoading"`
	LastChapterName  string   `json:"lastChapterName"`
	NewChapters      int      `json:"newChapters"`
	NoteURL          string   `json:"noteUrl"`
	SerialNumber     int      `json:"serialNumber"`
	Tag              string   `json:"tag"`
	UseReplaceRule   bool     `json:"useReplaceRule"`
}

type SourceRule

type SourceRule struct {
	Mode string `json:"mode"`
	Rule string `json:"rule"`
	Js   string `json:"js"`
}

type UnixTime

type UnixTime time.Time

func (UnixTime) MarshalJSON

func (t UnixTime) MarshalJSON() ([]byte, error)

func (*UnixTime) UnmarshalJSON

func (t *UnixTime) UnmarshalJSON(data []byte) (err error)

Jump to

Keyboard shortcuts

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