Documentation ¶
Index ¶
- Variables
- func AddBook(b *Book, basePath string, minPageNum int) error
- func AddBooks(list []*Book, basePath string, minPageNum int) (err error)
- func ClearTempFilesALL(debug bool, cacheFilePath string)
- func DeleteBookByID(bookID string)
- func GetBooksNumber() int
- type AllPageInfo
- type Book
- func (b *Book) GetAllPageNum() int
- func (b *Book) GetAuthor() string
- func (b *Book) GetBookID() string
- func (b *Book) GetFilePath() string
- func (b *Book) GetName() string
- func (b *Book) ScanAllImage()
- func (b *Book) ScanAllImageGo()
- func (b *Book) SortPages(s string)
- func (b *Book) SortPagesByImageList(imageList []string)
- type BookInfo
- type BookInfoList
- func GetAllBookInfoList(sortBy string) (*BookInfoList, error)
- func GetBookInfoListByBookGroupBookID(BookID string, sortBy string) (*BookInfoList, error)
- func GetBookInfoListByDepth(depth int, sortBy string) (*BookInfoList, error)
- func GetBookInfoListByMaxDepth(depth int, sortBy string) (*BookInfoList, error)
- type Bookstores
- type ImageInfo
- type SupportFileType
Constants ¶
This section is empty.
Variables ¶
View Source
var ( Stores = Bookstores{ SortBy: "name", // contains filtered or unexported fields } )
Functions ¶
func ClearTempFilesALL ¶
ClearTempFilesALL web加载时保存的临时图片,在在退出后清理
Types ¶
type AllPageInfo ¶
func (AllPageInfo) Len ¶
func (s AllPageInfo) Len() int
func (AllPageInfo) Swap ¶
func (s AllPageInfo) Swap(i, j int)
type Book ¶
type Book struct { //Name string `json:"name"` //书名 //BookID string `json:"id"` //根据FilePath+BookType+修改时间+filesize等等计算,bookID应该唯一 //FilePath string `json:"-" storm:"filepath"` //文件路径 //BookStorePath string `json:"-" ` //在哪个子书库 //Type SupportFileType `json:"book_type"` //可以是书籍组(book_group)、文件夹(dir)、文件后缀( .zip .rar .pdf .mp4)等 //ChildBookNum int `json:"child_book_num"` //子书籍的数量 //Depth int `json:"depth"` //文件深度 //ParentFolder string `json:"parent_folder"` //所在父文件夹 //AllPageNum int `json:"all_page_num"` //storm:"index" 索引字段 //FileSize int64 `json:"file_size"` //storm:"index" 索引字段 //Author string `json:"author"` //作者 //Modified time.Time `json:"modified_time"` //最后修改时间 //ReadPercent float64 `json:"read_percent"` //阅读进度 //ISBN string `json:"-"` //json不解析,启用可改为`json:"isbn"` //Press string `json:"-"` //json不解析,启用可改为`json:"press"` //出版社 //PublishedAt string `json:"-"` //json不解析,启用可改为`json:"published_at"` //出版日期 //ExtractPath string `json:"-"` //json不解析 //ExtractNum int `json:"-"` //json不解析,启用可改为`json:"extract_num"` //InitComplete bool `json:"-"` //json不解析,启用可改为`json:"extract_complete"` //NonUTF8Zip bool `json:"-"` //json不解析,启用可改为`json:"non_utf8_zip"` //ZipTextEncoding string `json:"-"` //json不解析,启用可改为`json:"zip_text_encoding"` //Cover ImageInfo `json:"cover"` //storm:"inline" 内联字段,结构体嵌套时使用 BookInfo Pages AllPageInfo `json:"pages"` //storm:"inline" 内联字段,结构体嵌套时使用 ChildBook map[string]*Book `json:"child_book" ` //key:BookID }
Book 定义书籍,BooID不应该重复,根据文件路径生成
func GetAllBookList ¶
func GetAllBookList() []*Book
func GetBookByAuthor ¶
GetBookByAuthor 获取同一作者的书籍。
func GetBookByID ¶
GetBookByID 获取特定书籍,复制一份数据
func New ¶
func New(filePath string, modified time.Time, fileSize int64, storePath string, depth int, bookType SupportFileType) (*Book, error)
New 初始化Book,设置文件路径、书名、BookID等等
func (*Book) GetAllPageNum ¶
func (*Book) GetFilePath ¶
func (*Book) SortPagesByImageList ¶ added in v0.9.0
SortPagesByImageList 根据一个既定的文件列表,重新对页面排序。用于epub文件。
type BookInfo ¶
type BookInfo struct { Name string `json:"name"` //书名 BookID string `json:"id"` //根据FilePath生成的唯一ID BookStorePath string `json:"-" ` //在哪个子书库 Type SupportFileType `json:"book_type"` //书籍类型 Depth int `json:"depth"` //书籍深度 ChildBookNum int `json:"child_book_num"` //子书籍数量 AllPageNum int `json:"all_page_num"` //总页数 Cover ImageInfo `json:"cover"` //封面图 ParentFolder string `json:"parent_folder"` //父文件夹 Author string `json:"author"` //作者 ISBN string `json:"isbn"` //ISBN Press string `json:"press"` //出版社 PublishedAt string `json:"published_at"` //出版日期 FilePath string `json:"-"` //文件绝对路径,json不解析 FileSize int64 `json:"file_size"` //文件大小 Modified time.Time `json:"modified_time"` //修改时间 ExtractPath string `json:"-"` //解压路径,7z用,json不解析 ExtractNum int `json:"-"` //文件解压数 extract_num InitComplete bool `json:"-"` //是否解压完成 extract_complete ReadPercent float64 `json:"read_percent"` //阅读进度 NonUTF8Zip bool `json:"-"` //是否为特殊编码zip ZipTextEncoding string `json:"-"` //zip文件编码 }
BookInfo 与Book唯一的区别是没有AllPageInfo,而是封面图URL 减小 json文件的大小
type BookInfoList ¶
type BookInfoList struct { BookInfos []BookInfo // contains filtered or unexported fields }
BookInfoList Slice
func GetAllBookInfoList ¶
func GetAllBookInfoList(sortBy string) (*BookInfoList, error)
func GetBookInfoListByBookGroupBookID ¶
func GetBookInfoListByBookGroupBookID(BookID string, sortBy string) (*BookInfoList, error)
func GetBookInfoListByDepth ¶
func GetBookInfoListByDepth(depth int, sortBy string) (*BookInfoList, error)
func GetBookInfoListByMaxDepth ¶
func GetBookInfoListByMaxDepth(depth int, sortBy string) (*BookInfoList, error)
func (BookInfoList) Len ¶
func (s BookInfoList) Len() int
func (*BookInfoList) SortBooks ¶
func (s *BookInfoList) SortBooks(by string)
SortBooks 上面三个函数定义好了,终于可以使用sort包排序了
func (BookInfoList) Swap ¶
func (s BookInfoList) Swap(i, j int)
type Bookstores ¶
type Bookstores struct { SortBy string // contains filtered or unexported fields }
Bookstores 本地总书库,扫描后生成。可以有多个子书库。
func (*Bookstores) AddBookToStores ¶
func (bs *Bookstores) AddBookToStores(searchPath string, b *Book) error
AddBookToStores 将某一本书,放到basePath做key的某子书库中
func (*Bookstores) GenerateBookGroup ¶
func (bs *Bookstores) GenerateBookGroup() error
GenerateBookGroup 生成书籍组
func (*Bookstores) NewSingleBookstore ¶
func (bs *Bookstores) NewSingleBookstore(basePath string) error
NewSingleBookstore 创建一个新书库
type ImageInfo ¶
type ImageInfo struct { PageNum int `json:"-"` //这个字段不解析 NameInArchive string `json:"filename"` //用于解压的压缩文件内文件路径,或图片名,为了适应特殊字符,经过一次转义 Url string `json:"url"` //远程用户读取图片的URL,为了适应特殊字符,经过一次转义 Blurhash string `json:"-"` //`json:"blurhash"` //blurhash占位符。需要扫描图片生成(tools.GetImageDataBlurHash) Height int `json:"-"` //暂时用不着 这个字段不解析`json:"height"` //blurhash用,图片高 Width int `json:"-"` //暂时用不着 这个字段不解析`json:"width"` //blurhash用,图片宽 ModeTime time.Time `json:"-"` //这个字段不解析 FileSize int64 `json:"-"` //这个字段不解析 RealImageFilePATH string `json:"-"` //这个字段不解析 书籍为文件夹的时候,实际图片的路径 ImgType string `json:"-"` //这个字段不解析 }
ImageInfo 单张书页
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
Click to show internal directories.
Click to hide internal directories.