Documentation
¶
Index ¶
- Variables
- func AddBook(b *Book, basePath string, minPageNum int) error
- func AddBooks(list []*Book, basePath string, minPageNum int) error
- func CheckAllBookFileExist()
- func CheckBookExist(filePath string, bookType SupportFileType) bool
- func ClearAllBookData()
- func ClearBookData()
- func ClearBookGroupData()
- func ClearTempFilesALL(debug bool, cacheFilePath string)
- func DeleteBookByID(bookID string)
- func GetBookGroupIDByBookID(id string) (string, error)
- func GetBooksNumber() int
- func ResetBookGroupData()
- func RestoreDatabaseBooks(list []*Book)
- type Book
- func GetAllBookList() []*Book
- func GetArchiveBooks() []*Book
- func GetBookByAuthor(author string, sortBy string) ([]*Book, error)
- func GetBookByID(id string, sortBy string) (*Book, error)
- func GetRandomBook() (*Book, error)
- func NewBook(filePath string, modified time.Time, fileSize int64, storePath string, ...) (*Book, error)
- func (b *Book) GetAuthor() string
- func (b *Book) GetBookID() string
- func (b *Book) GetFilePath() string
- func (b *Book) GetPageCount() int
- func (b *Book) GuestCover() (cover MediaFileInfo)
- func (b *Book) ScanAllImage()
- func (b *Book) ScanAllImageGo()
- func (b *Book) SortPages(s string)
- func (b *Book) SortPagesByImageList(imageList []string)
- type BookGroup
- type BookInfo
- type BookInfoList
- func GetAllBookInfoList(sortBy string) (*BookInfoList, error)
- func GetBookInfoListByDepth(depth int, sortBy string) (*BookInfoList, error)
- func GetBookInfoListByID(BookID string, sortBy string) (*BookInfoList, error)
- func GetBookInfoListByMaxDepth(depth int, sortBy string) (*BookInfoList, error)
- func GetBookInfoListByParentFolder(parentFolder string, sortBy string) (*BookInfoList, error)
- func TopOfShelfInfo(sortBy string) (*BookInfoList, error)
- type DirNode
- type MediaFileInfo
- type Pages
- type ReadingProgress
- type Store
- type SupportFileType
- type User
Constants ¶
This section is empty.
Variables ¶
var ( // MainStore 带有层级关系的总书组,用于前端展示 MainStore = Store{} )
使用并发安全的 sync.Map 存储书籍和书组
Functions ¶
func CheckAllBookFileExist ¶
func CheckAllBookFileExist()
CheckAllBookFileExist 检查内存中的书的源文件是否存在,不存在就删掉
func CheckBookExist ¶
func CheckBookExist(filePath string, bookType SupportFileType) bool
CheckBookExist 查看内存中是否已经有了这本书,有了就返回 true,让调用者跳过
func ClearTempFilesALL ¶
ClearTempFilesALL 清理所有缓存的临时图片
func GetBookGroupIDByBookID ¶
GetBookGroupIDByBookID 通过子书籍 ID 获取所属书组 ID
func RestoreDatabaseBooks ¶
func RestoreDatabaseBooks(list []*Book)
RestoreDatabaseBooks 从数据库中读取的书籍信息,放到内存中
Types ¶
type Book ¶
Book 定义书籍结构
func GetBookByAuthor ¶
GetBookByAuthor 获取同一作者的书籍
func GetBookByID ¶
GetBookByID 根据 BookID 获取书籍
func NewBook ¶
func NewBook(filePath string, modified time.Time, fileSize int64, storePath string, depth int, bookType SupportFileType) (*Book, error)
NewBook 初始化 Book,设置文件路径、书名、BookID 等
func (*Book) SortPagesByImageList ¶
SortPagesByImageList 根据给定的文件列表排序页面(用于 EPUB)
type BookGroup ¶
func GetBookGroupByBookID ¶
GetBookGroupByBookID 通过数组 ID 获取书组信息
func GetBookGroupInfoByChildBookID ¶
GetBookGroupInfoByChildBookID 通过子书籍 ID 获取所属书组信息
type BookInfo ¶
type BookInfo struct {
Author string `json:"author"` // 作者
BookID string `json:"id"` // 根据 FilePath 生成的唯一 ID
BookStorePath string `json:"-"` // 在哪个子书库
ChildBookNum int `json:"child_book_num"` // 子书籍数量
Cover MediaFileInfo `json:"cover"` // 封面图
Deleted bool `json:"deleted"` // 源文件是否已删除
Depth int `json:"depth"` // 书籍深度
ExtractPath string `json:"-"` // 解压路径,7z 用,JSON 不解析
ExtractNum int `json:"-"` // 文件解压数
FileSize int64 `json:"file_size"` // 文件大小
FilePath string `json:"-"` // 文件绝对路径,JSON 不解析
ISBN string `json:"isbn"` // ISBN
InitComplete bool `json:"-"` // 是否解压完成
Modified time.Time `json:"modified_time"` // 修改时间
NonUTF8Zip bool `json:"-"` // 是否为特殊编码 zip
PageCount int `json:"page_count"` // 总页数
ParentFolder string `json:"parent_folder"` // 父文件夹
Press string `json:"press"` // 出版社
PublishedAt string `json:"published_at"` // 出版日期
ReadPercent float64 `json:"read_percent"` // 阅读进度
Title string `json:"title"` // 书名
Type SupportFileType `json:"type"` // 书籍类型
ZipTextEncoding string `json:"-"` // zip 文件编码
}
BookInfo 与 Book 唯一的区别是没有 AllPageInfo,而是封面图 URL,减小 JSON 文件的大小
type BookInfoList ¶
type BookInfoList struct {
BookInfos []BookInfo
}
BookInfoList 表示 BookInfo 的列表
func GetAllBookInfoList ¶
func GetAllBookInfoList(sortBy string) (*BookInfoList, error)
GetAllBookInfoList 获取所有 BookInfo,并根据 sortBy 参数进行排序
func GetBookInfoListByDepth ¶
func GetBookInfoListByDepth(depth int, sortBy string) (*BookInfoList, error)
GetBookInfoListByDepth 根据深度获取书籍列表
func GetBookInfoListByID ¶
func GetBookInfoListByID(BookID string, sortBy string) (*BookInfoList, error)
GetBookInfoListByID 根据 ID 获取书籍列表
func GetBookInfoListByMaxDepth ¶
func GetBookInfoListByMaxDepth(depth int, sortBy string) (*BookInfoList, error)
GetBookInfoListByMaxDepth 获取指定最大深度的书籍列表
func GetBookInfoListByParentFolder ¶
func GetBookInfoListByParentFolder(parentFolder string, sortBy string) (*BookInfoList, error)
GetBookInfoListByParentFolder 根据父文件夹获取书籍列表
func TopOfShelfInfo ¶
func TopOfShelfInfo(sortBy string) (*BookInfoList, error)
TopOfShelfInfo 获取顶层书架信息
func (*BookInfoList) SortBooks ¶
func (s *BookInfoList) SortBooks(sortBy string)
SortBooks 根据 sortBy 参数对 BookInfos 进行排序
type DirNode ¶
type DirNode struct {
Name string `json:"name"`
Path string `json:"path"`
SubDirs []DirNode `json:"sub_dirs"` // 子目录列表
Files []MediaFileInfo `json:"files"` // 本目录下的图片文件列表
}
DirNode 表示目录树节点,用于 JSON 存储模式
type MediaFileInfo ¶
type MediaFileInfo struct {
Name string `json:"name"` // 用于解压的压缩文件内文件路径,或图片名,为了适应特殊字符,经过一次转义
Path string `json:"path"` // 文件路径
Size int64 `json:"size"` // 文件大小
ModTime time.Time `json:"mod_time"` // 修改时间
Url string `json:"url"` // 远程用户读取图片的URL,为了适应特殊字符,经过转义
PageNum int `json:"-"` // 这个字段不解析
Blurhash string `json:"-"` // `json:"blurhash"` //blurhash占位符。扫描图片生成(util.GetImageDataBlurHash)
Height int `json:"-"` // 暂时用不着 这个字段不解析`json:"height"` //blurhash用,图片高
Width int `json:"-"` // 暂时用不着 这个字段不解析`json:"width"` //blurhash用,图片宽
ImgType string `json:"-"` // 这个字段不解析
InsertHtml string `json:"-"` // 这个字段不解析
}
MediaFileInfo 单个媒体文件的信息
type Pages ¶
type Pages struct {
Images []MediaFileInfo `json:"images"`
SortBy string `json:"sort_by"`
}
Pages 定义页面结构
type ReadingProgress ¶
type ReadingProgress struct {
// 当前页
NowPageNum int `json:"nowPageNum"`
// 当前章节
NowChapterNum int `json:"nowChapterNum"`
// 阅读时间,单位为秒
ReadingTime int `json:"readingTime"`
}
func GetReadingProgress ¶
func GetReadingProgress(progress string) (ReadingProgress, error)
type Store ¶
Store 本地总书库,扫描后生成。可以有多个子书库。
func (*Store) AddBookToSubStore ¶
AddBookToSubStore 将某一本书,放到BookMap里面去
func (*Store) AddSubStore ¶
AddSubStore 创建一个新文件夹
type SupportFileType ¶
type SupportFileType string
const ( TypeDir SupportFileType = "dir" TypeZip SupportFileType = ".zip" TypeRar SupportFileType = ".rar" TypeBooksGroup SupportFileType = "book_group" TypeCbz SupportFileType = ".cbz" TypeCbr SupportFileType = ".cbr" TypeTar SupportFileType = ".tar" TypeEpub SupportFileType = ".epub" TypePDF SupportFileType = ".pdf" TypeVideo SupportFileType = "video" TypeAudio SupportFileType = "audio" TypeUnknownFile SupportFileType = "unknown" )
书籍类型
func GetBookTypeByFilename ¶
func GetBookTypeByFilename(filename string) SupportFileType
GetBookTypeByFilename 初始化Book时,取得BookType