ebook

package
v0.34.0 Latest Latest
Warning

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

Go to latest
Published: May 21, 2020 License: MIT Imports: 12 Imported by: 1

Documentation

Index

Constants

View Source
const (
	LocalSource  = "Epub"
	OnlineSource = "Online"
)

Variables

View Source
var MetadataFieldNames = []string{authorField, translatorField, editorField, contributorField, titleField, yearField, editionYearField, editionInfoField, isbnField, publisherField, descriptionField, languageField, categoryField, typeField, genreField, tagsField, seriesField, formatField, numPagesField}

MetadataFieldNames is a list of valid field names

Functions

func AskForISBN added in v0.9.0

func AskForISBN() (string, error)

AskForISBN when not found in epub

func CleanCategory added in v0.9.0

func CleanCategory(category string) (string, error)

func CleanDescription added in v0.9.0

func CleanDescription(desc string) string

func CleanLanguage added in v0.9.0

func CleanLanguage(language string) string

func CleanType added in v0.9.0

func CleanType(typ string) (string, error)

Types

type Author added in v0.10.0

type Author struct {
	Name string `json:"name" xml:"name"`
	Role string `json:"role" xml:"role"`
}

type ISBN added in v0.10.0

type ISBN struct {
	ISBN10   string
	ISBN13   string
	Location string
	Context  []string
}

func CleanISBN

func CleanISBN(full string) ([]ISBN, error)

CleanISBN from a string

func (ISBN) Info added in v0.10.0

func (i ISBN) Info() string

func (ISBN) String added in v0.10.0

func (i ISBN) String() string

type ISBNs added in v0.10.0

type ISBNs []ISBN

func (*ISBNs) Add added in v0.10.0

func (is *ISBNs) Add(i ISBN)

func (*ISBNs) HasISBN13 added in v0.10.0

func (is *ISBNs) HasISBN13(isbn string) (bool, int)

type Metadata

type Metadata struct {
	Title        string   `json:"title" xml:"title"`
	Authors      []Author `json:"authors" xml:"authors>author"`
	ISBN         string   `json:"isbn" xml:"isbn13"`
	Format       string   `json:"format" xml:"format"`
	OriginalYear string   `json:"year" xml:"work>original_publication_year"`
	EditionYear  string   `json:"edition_year" xml:"publication_year"`
	EditionInfo  string   `json:"edition_information" xml:"edition_information"`
	NumPages     string   `json:"num_pages" xml:"num_pages"`
	Language     string   `json:"language" xml:"language_code"`
	Publisher    string   `json:"publisher" xml:"publisher"`
	Description  string   `json:"description" xml:"description"`
	Series       Series   `json:"series" xml:"series_works>series_work"`
	Tags         Tags     `json:"tags" xml:"popular_shelves>shelf"`
	Category     string   `json:"category"`
	Type         string   `json:"type"`
	Genre        string   `json:"genre"`
	ImageURL     string   `json:"image_url" xml:"image_url"`
}

Metadata contains all of the known book metadata.

func (*Metadata) Author added in v0.10.0

func (m *Metadata) Author() string

Author returns Metadata's main author.

func (*Metadata) Clean added in v0.10.0

func (m *Metadata) Clean()

Clean cleans up the Metadata

func (*Metadata) CleanSpecific added in v0.14.0

func (m *Metadata) CleanSpecific(forbiddenTags []string, tagAliases map[string][]string)

CleanSpecific cleans up the Metadata with specific lists of forbidden tags or aliases

func (*Metadata) Contributor added in v0.14.0

func (m *Metadata) Contributor() string

Contributor returns Metadata's Contributor(s).

func (*Metadata) Diff added in v0.13.0

func (m *Metadata) Diff(o *Metadata, diffOnly bool) [][]string

Diff returns differences between Metadatas.

func (*Metadata) Editor added in v0.14.0

func (m *Metadata) Editor() string

Editor returns Metadata's Editor(s).

func (*Metadata) Get added in v0.13.0

func (m *Metadata) Get(field string) (string, error)

Get Metadata field value

func (*Metadata) GetInfo added in v0.13.0

func (m *Metadata) GetInfo(fields ...string) [][]string

GetInfo returns a table with relevant information about a book.

func (*Metadata) MainSeries added in v0.10.0

func (m *Metadata) MainSeries() SingleSeries

MainSeries return the main Series of Metadata.

func (*Metadata) Merge added in v0.13.0

func (m *Metadata) Merge(o *Metadata, diffOnly bool) (err error)

Merge with another Metadata.

func (*Metadata) MergeField added in v0.13.0

func (m *Metadata) MergeField(o *Metadata, field string, diffOnly bool) error

MergeField with another Metadata.

func (*Metadata) Set added in v0.13.0

func (m *Metadata) Set(field, value string) error

Set Metadata field with a string value

func (*Metadata) Source added in v0.10.0

func (m *Metadata) Source() string

Source returns a representation of Metadata

func (*Metadata) String added in v0.10.0

func (m *Metadata) String() string

String returns a representation of Metadata

func (*Metadata) Translator added in v0.14.0

func (m *Metadata) Translator() string

Translator returns Metadata's Translator(s).

type Series

type Series []SingleSeries

Series can track a series and the position of an epub.

func (*Series) AddFromString added in v0.9.0

func (s *Series) AddFromString(candidate string) (bool, error)

AddFromString a series, checking for correct form.

func (*Series) Has added in v0.9.0

func (s *Series) Has(seriesName string) (hasSeries bool, index int, position string)

Has checks if epub is part of a series

func (*Series) HasAny added in v0.9.0

func (s *Series) HasAny() bool

HasAny checks if epub is part of any series

func (Series) String added in v0.9.0

func (s Series) String() string

String outputs a series info.

type SingleSeries

type SingleSeries struct {
	Name     string `json:"name" xml:"series>title"`
	Position string `json:"index" xml:"user_position"`
}

SingleSeries holds the name and index of a series a Book is part of.

func (SingleSeries) String added in v0.9.0

func (s SingleSeries) String() string

String outputs a single series info.

type Tag

type Tag struct {
	Name string `json:"name" xml:"name,attr"`
}

Tag holds the name of a tag.

type Tags

type Tags []Tag

Tags can track a book's Tags

func (*Tags) Add added in v0.9.0

func (t *Tags) Add(tags ...Tag) (added bool)

Add Tags to the list

func (*Tags) AddFromNames added in v0.9.0

func (t *Tags) AddFromNames(tags ...string) bool

AddFromNames Tags to the list, from []string

func (*Tags) Clean added in v0.9.0

func (t *Tags) Clean(otherForbidden []string, otherAliases map[string][]string)

func (*Tags) Has added in v0.9.0

func (t *Tags) Has(o Tag) (isIn bool, index int)

Has finds out if a Tag is already in list.

func (*Tags) HasAny added in v0.9.0

func (t *Tags) HasAny() bool

HasAny checks if epub is part of any series

func (*Tags) HasTag added in v0.13.0

func (t *Tags) HasTag(tagName string) bool

HasTag finds out if a Tag name is already in list.

func (*Tags) Remove added in v0.9.0

func (t *Tags) Remove(tags ...Tag) (removed bool)

Remove Tags from the list

func (*Tags) RemoveFromNames added in v0.9.0

func (t *Tags) RemoveFromNames(tags ...string) bool

RemoveFromNames Tags to the list, from []string

func (*Tags) Slice added in v0.13.0

func (t *Tags) Slice() []string

func (*Tags) String added in v0.9.0

func (t *Tags) String() string

String give a string representation of Tags.

Jump to

Keyboard shortcuts

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