book

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2022 License: BSD-2-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Verbose is the logger of book package that provides feedback of operation
	// done on books.
	Verbose = log.New(io.Discard, log.Prefix(), log.Flags())

	// Debug is the logger of book package that provides information for
	// debugging purpose.
	Debug = log.New(io.Discard, log.Prefix(), log.Flags())

	// ErrUnknownFormat is raised if supplied file format is unknown.
	ErrUnknownFormat = errors.New("unknown file format")
)

Functions

func ParseTime

func ParseTime(text string) (t time.Time, err error)

ParseTime parses a time stamp, trying different time format.

Types

type Book

type Book struct {
	// Path is the location of the book's file in the file-system.
	Path string

	// Title is the book's title.
	Title string

	// Authors is the list names of the authors and/or editors for this book.
	Authors []string

	// ISBN is the unique industry standard identifier for this book.
	ISBN string `json:",omitempty"`

	// SubTitle is the book's sub-title.
	SubTitle string `json:",omitempty"`

	// Publisher is the publisher of this book.
	Publisher string `json:",omitempty"`

	// PublishedDate is the date of publication of this book.
	PublishedDate string `json:",omitempty"`

	// Description is the synopsis of the book. The text of the description
	// is formatted in HTML and includes simple formatting elements.
	Description string `json:",omitempty"`

	// Series is the series to which this book belongs to.
	Series string `json:",omitempty"`

	// SeriesIndex is the position in the series to which the book belongs to.
	SeriesIndex float64 `json:",omitempty"`

	// SeriesTitle is the book's title in th eseries (whithout Series nor
	// SubTitle information).
	SeriesTitle string `json:",omitempty"`

	// Language is the book's language. It is the two-letter ISO 639-1 code
	// such as 'fr', 'en'.
	Language string `json:",omitempty"`

	// PageCount is total number of pages of this book.
	PageCount int `json:",omitempty"`

	// Categories is the list of subject categories, such as "Fiction",
	// "Suspense".
	Categories []string `json:",omitempty"`
}

Book represents a book.

func New

func New() *Book

New creates a new Book

func NewFromFile

func NewFromFile(path string) (*Book, error)

NewFromFile creates a new Book and populates its information according to the file's metadata.

func (*Book) Clean

func (b *Book) Clean()

Clean makes sure that Book's metadata are in a reasonable format like pure text.

dehtmlizer is pretty basic so only a sub-part of html formats are correctly interpreted.

func (*Book) FromEpub

func (b *Book) FromEpub() error

FromEpub populates a Book's information out of an EPUB file's Metadata.

func (*Book) FromFile

func (b *Book) FromFile() error

FromFile populates Book's information according to the file's metadata.

func (*Book) FromMap

func (b *Book) FromMap(m map[string]string, override bool) error

FromMap updates a Book's information according to the attributes defined as a map where keys are attribute's name (insensitive to case) and value is a string representation of the attribute's value. For attributes that accept a list of values (like Authors or Categories), provided map value should be formatted like "val0 & val1" (individual value in as string separated by '&'). If override flag is on, existing Book's attribute is replaced by the one provided in the map ; if override flag is off, Book's attribute is only replaced if empty.

func (*Book) Guess

func (b *Book) Guess() error

Guess tries to guess Book's information based on known attributes (like Book's path, Book's Title).

func (*Book) IsComplete

func (b *Book) IsComplete() bool

IsComplete gives an evaluation whether a Book's information seems complete enough. Objective is to provide a way for the tool to decide whether a human intervention is a good idea.

func (Book) String

func (b Book) String() string

String proposes an easy-to-read raw representation of a Book.

Jump to

Keyboard shortcuts

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