file

package
v0.9.11 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2024 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CountPagesOfPDF

func CountPagesOfPDF(pdfFileName string) (int, error)

CountPagesOfPDF 确定PDF的页数

func ExportAllImageFromPDF

func ExportAllImageFromPDF(pdfFile string)

func ExportImageFromPDF

func ExportImageFromPDF(pdfFile string, pageNum int)

func GetFileFromCache

func GetFileFromCache(id string, filename string, queryString string, isCover bool, cachePath string, debug bool) ([]byte, string, error)

读取缓存,加快第二次访问的速度

func GetImageFromPDF

func GetImageFromPDF(pdfFileName string, pageNum int, Debug bool) ([]byte, error)

GetImageFromPDF 从PDF里面取jpeg文件,pageNum从1开始

func GetImageListFromEpubFile

func GetImageListFromEpubFile(epubPath string) (imageList []string, err error)

GetImageListFromEpubFile 根据Epub信息,获取有序的imgSrc列表

func GetPageDimensions

func GetPageDimensions(fileName string) []dim

取得PDF页面分辨率

func GetPictureData

func GetPictureData(option GetPictureDataOption) (imgData []byte, contentType string, err error)

func GetQueryString

func GetQueryString(query url.Values) string

根据query生成一个key string,用到两个第三方库

func GetSingleFile

func GetSingleFile(filePath string, NameInArchive string, textEncoding string) ([]byte, error)

GetSingleFile 获取单个文件 TODO:大文件需要针对性优化,可能需要保持打开状态、或通过持久化的虚拟文件系统获取 TODO:可选择文件缓存功能,一旦解压,下次直接读缓存文件

func SaveFileToCache

func SaveFileToCache(id string, filename string, data []byte, queryString string, contentType string, isCover bool, cachePath string, debug bool) error

SaveFileToCache 读取过一次的文件,就保存到硬盘上加快读取

func ScanNonUTF8Zip

func ScanNonUTF8Zip(filePath string, textEncoding string) (reader *zip.Reader, err error)

ScanNonUTF8Zip 扫描文件,初始化书籍用

func UnArchiveRar

func UnArchiveRar(filePath string, extractPath string) error

UnArchiveRar 一次性解压rar文件

func UnArchiveZip

func UnArchiveZip(filePath string, extractPath string, textEncoding string) error

UnArchiveZip 一次性解压zip文件

Types

type Container

type Container struct {
	XMLName   xml.Name `xml:"container"`
	Text      string   `xml:",chardata"`
	Version   string   `xml:"version,attr"`
	Xmlns     string   `xml:"xmlns,attr"`
	Rootfiles struct {
		Text     string `xml:",chardata"`
		Rootfile struct {
			Text      string `xml:",chardata"`
			FullPath  string `xml:"full-path,attr"`
			MediaType string `xml:"media-type,attr"`
		} `xml:"rootfile"`
	} `xml:"rootfiles"`
}

Container 定义结构体、映射xml结构 was generated 2022-12-09 00:41:31 by https://xml-to-go.github.io/ in Ukraine.

type EpubMetadata

type EpubMetadata struct {
	Title     string `xml:"title"`
	Language  string `xml:"language"`
	Creator   string `xml:"creator"`
	Publisher string `xml:"publisher"`
	Date      string `xml:"date"`
	Rights    string `xml:"rights"`
	Series    string `xml:"series"`
}

func GetEpubMetadata

func GetEpubMetadata(epubPath string) (metadata EpubMetadata, err error)

GetEpubMetadata 根据Epub信息,获取书籍详情

type GetPictureDataOption

type GetPictureDataOption struct {
	PictureName      string
	BookIsDir        bool
	BookIsPDF        bool
	BookIsNonUTF8Zip bool
	BookFilePath     string
	Debug            bool
	UseCache         bool
	ResizeWidth      int
	ResizeHeight     int
	ResizeMaxWidth   int
	ResizeMaxHeight  int
	ThumbnailMode    bool
	AutoCrop         int
	Gray             bool
	BlurHash         int
	BlurHashImage    int
}

type Package

type Package struct {
	XMLName          xml.Name `xml:"package"`
	Text             string   `xml:",chardata"`
	Version          string   `xml:"version,attr"`
	UniqueIdentifier string   `xml:"unique-identifier,attr"`
	Xmlns            string   `xml:"xmlns,attr"`
	Metadata         struct {
		Text string `xml:",chardata"`
		Dc   string `xml:"dc,attr"`
		Opf  string `xml:"opf,attr"`
		Meta []struct {
			Text    string `xml:",chardata"`
			Name    string `xml:"name,attr"`
			Content string `xml:"content,attr"`
		} `xml:"meta"`
		Identifier struct {
			Text   string `xml:",chardata"`
			ID     string `xml:"id,attr"`
			Scheme string `xml:"scheme,attr"`
		} `xml:"identifier"`
		Title     string `xml:"title"`
		Language  string `xml:"language"`
		Creator   string `xml:"creator"`
		Publisher string `xml:"publisher"`
		Date      string `xml:"date"`
		Rights    string `xml:"rights"`
		Series    string `xml:"series"`
	} `xml:"metadata"`
	Manifest struct {
		Text string `xml:",chardata"`
		Item []struct {
			Text       string `xml:",chardata"`
			ID         string `xml:"id,attr"`
			Href       string `xml:"href,attr"`
			MediaType  string `xml:"media-type,attr"`
			Properties string `xml:"properties,attr"`
		} `xml:"item"`
	} `xml:"manifest"`
	Spine struct {
		Text    string `xml:",chardata"`
		Toc     string `xml:"toc,attr"`
		Itemref []struct {
			Text  string `xml:",chardata"`
			Idref string `xml:"idref,attr"`
		} `xml:"itemref"`
	} `xml:"spine"`
	Guide struct {
		Text      string `xml:",chardata"`
		Reference struct {
			Text  string `xml:",chardata"`
			Type  string `xml:"type,attr"`
			Href  string `xml:"href,attr"`
			Title string `xml:"title,attr"`
		} `xml:"reference"`
	} `xml:"guide"`
}

Package 定义结构体、映射OPF文件(xml)结构用。 was generated 2022-12-09 00:47:41 by https://xml-to-go.github.io/ in Ukraine.

type SyncMap

type SyncMap struct {
	sync.RWMutex // map不是并发安全的 , 当有多个并发的goroutine读写同一个map时会出现panic错误(fatal error: concurrent map writes)
	// contains filtered or unexported fields
}

SyncMap 有读写锁的map

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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