metadata

package
v4.21.0 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2026 License: GPL-3.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FmtDuration added in v4.15.0

func FmtDuration(d time.Duration) string

FmtDuration formats a duration as "Xd Yh Zm" or "Yh Zm" if less than 24 hours

func ParseAuthorList added in v4.21.0

func ParseAuthorList(s string) []string

ParseAuthorList splits s by '&', ',', and ';', trims each part, and returns non-empty names. Used for both EPUB creator lists and PDF author strings.

func SanitizeDescription added in v4.21.0

func SanitizeDescription(raw string) string

SanitizeDescription returns sanitized HTML for use in Metadata.Description. If raw is empty or only whitespace, returns "". If raw contains no HTML (strict sanitize unchanged), wraps newline-separated paragraphs in <p>. Otherwise sanitizes with a policy that allows allowedDescriptionElements.

Types

type EpubReader

type EpubReader struct {
	GetMetadataFromFile func(path string) (*epub.Information, error)
	GetPackageFromFile  func(path string) (*epub.PackageDocument, error)
}

func NewEpubReader added in v4.4.0

func NewEpubReader() EpubReader

func (EpubReader) Cover

func (e EpubReader) Cover(documentFullPath string, coverMaxWidth int) ([]byte, error)

Cover parses the document looking for a cover image and returns it

func (EpubReader) Metadata

func (e EpubReader) Metadata(filename string) (Metadata, error)

type Metadata

type Metadata struct {
	Title         string
	Authors       []string
	Description   template.HTML
	Language      string
	Publication   precisiondate.PrecisionDate
	Words         float64
	Series        string
	SeriesIndex   float64
	Pages         float64
	Format        string
	Subjects      []string
	Illustrations int
}

func (Metadata) ReadingTime

func (m Metadata) ReadingTime(wordsPerMinute float64) string

type PdfReader

type PdfReader struct {
	Fs afero.Fs
}

func (PdfReader) Cover

func (p PdfReader) Cover(documentFullPath string, coverMaxWidth int) ([]byte, error)

Cover parses the document looking for a cover image and returns it

func (PdfReader) Illustrations added in v4.20.0

func (p PdfReader) Illustrations(documentFullPath string, minMegapixels float64) (int, error)

Illustrations returns the number of distinct embedded images with pixel count >= minMegapixels.

func (PdfReader) Metadata

func (p PdfReader) Metadata(file string) (Metadata, error)

type Reader

type Reader interface {
	Metadata(file string) (Metadata, error)
	Cover(documentFullPath string, coverMaxWidth int) ([]byte, error)
}

Jump to

Keyboard shortcuts

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