Documentation ¶
Index ¶
- Constants
- func AddedInThePastDays(d int) string
- func CheckLib(path string) error
- func ErrFileNotExist(path string) error
- func FileExist(path string) bool
- func ListCommands() []string
- func ListPreferences() []string
- func SrvIsOnline(u *url.URL) bool
- type Add
- type AddFormat
- type Book
- type BookDecoder
- type BookEncoder
- type CmdOpt
- type Command
- func (c *Command) Add(files ...string) *Add
- func (c *Command) AddFormat(id string, file string) *AddFormat
- func (c *Command) Build() *exec.Cmd
- func (c *Command) EmbedMetadata() *EmbedMetadata
- func (c *Command) Export(id ...string) *Export
- func (c *Command) Remove() *Remove
- func (c *Command) RemoveFormat(id string, fmt string) *RemoveFormat
- func (c *Command) Run() (string, error)
- func (c *Command) SavedSearchesAdd(name string, expression string) *SavedSearchesAdd
- func (c *Command) SavedSearchesList() *SavedSearchesList
- func (c *Command) SavedSearchesRemove(name string) *SavedSearchesRemove
- func (c *Command) SetArgs(args ...string)
- func (c *Command) SetFlags(flags ...string)
- func (c *Command) SetMetadata(id string) *SetMetadata
- func (c *Command) ShowMetadata(id string) *ShowMetadata
- type DB
- type Decoder
- type DecoderInit
- type EditableFields
- type EmbedMetadata
- type Encoder
- type EncoderInit
- type Export
- func (c *Export) DontAsciiize() *Export
- func (c *Export) DontSaveCover() *Export
- func (c *Export) DontUpdateMetadata() *Export
- func (c *Export) DontWriteOpf() *Export
- func (c *Export) Formats(v string) *Export
- func (c *Export) ReplaceWhitespace() *Export
- func (c *Export) SingleDir() *Export
- func (c *Export) Template(v string) *Export
- func (c *Export) Timefmt(v string) *Export
- func (c *Export) ToDir(v string) *Export
- func (c *Export) ToLowercase() *Export
- type Lib
- type Model
- type Models
- type Option
- type Query
- type Records
- type Remove
- type RemoveFormat
- type SavedSearchesAdd
- type SavedSearchesList
- type SavedSearchesRemove
- type Serializer
- func (s *Serializer) Decoder(init DecoderInit) *Serializer
- func (s *Serializer) Encoder(init EncoderInit) *Serializer
- func (s *Serializer) ReadFile(path string) error
- func (s *Serializer) ReadFrom(r io.Reader) error
- func (s *Serializer) WriteFile(name string) error
- func (s *Serializer) WriteTo(w io.Writer) error
- type SerializerOpt
- type SetMetadata
- type ShowMetadata
Constants ¶
const ( SavedSearches = "saved_searches" DisplayFields = "book_display_fields" HiddenCategories = "tag_browser_hidden_categories" FieldMetadata = "field_metadata" )
const ( Authors = "authors" AuthorSort = "author_sort" Comments = "comments" Cover = "cover" CustomColumns = "custom_columns" Formats = "formats" ID = "id" Identifiers = "identifiers" Languages = "languages" LastModified = "last_modified" Path = "path" Pubdate = "pubdate" Publisher = "publisher" Rating = "rating" Series = "series" SeriesIndex = "series_index" Sort = "sort" SortAs = "sort_as" Tags = "tags" Timestamp = "timestamp" Title = "title" UUID = "uuid" Duration = "duration" Narrators = "narrators" )
Variables ¶
This section is empty.
Functions ¶
func AddedInThePastDays ¶
AddedInThePastDays retrieves the past n days of records.
func ErrFileNotExist ¶
func ListCommands ¶
func ListCommands() []string
ListCommands lists the available calibredb commands.
func ListPreferences ¶
func ListPreferences() []string
ListPreferences lists the retrievable calibre preferences.
func SrvIsOnline ¶
SrvIsOnline tests if the calibredb content server is available.
Types ¶
type Add ¶
type Add struct {
*Command
}
Add represents 'calibredb add'.
func (*Add) Duplicates ¶
Duplicates sets the --duplicates flag for 'calibredb add'.
func (*Add) OneBookPerDirectory ¶
OneBookPerDirectory sets the --one_book_per_directory flag for 'calibredb add'.
type AddFormat ¶
type AddFormat struct {
*Command
}
AddFormat represents 'calibredb add_format'.
func (*AddFormat) DontReplace ¶
DontReplace sets the --dont_replace flag for 'calibredb add_format'.
type Book ¶
type Book struct { EditableFields `yaml:",inline" mapstructure:",squash"` Timestamp time.Time `db:"timestamp" yaml:"timestamp,omitempty" toml:"timestamp,omitempty" json:"timestamp,omitempty"` Cover string `db:"cover" yaml:"cover,omitempty" toml:"cover,omitempty" json:"cover,omitempty"` Formats []string `db:"formats" yaml:"formats,omitempty" toml:"formats,omitempty" json:"formats,omitempty"` LastModified time.Time `` /* 150-byte string literal not displayed */ ID int `db:"id" yaml:"id,omitempty" toml:"id,omitempty" json:"id,omitempty"` Path string `db:"path" yaml:"path,omitempty" toml:"path,omitempty" json:"path,omitempty"` UUID string `db:"uuid,omitempty" yaml:"uuid,omitempty" toml:"uuid,omitempty" json:"uuid,omitempty"` Source string `json:"source,omitempty" yaml:"-" toml:"-"` }
Book represents a book record.
func (*Book) CalibredbFlags ¶ added in v0.0.4
CalibredbFlags is a convenience method for returning a slice of metadata fields to use with the 'set_metadata' command.
func (Book) StringMapString ¶ added in v0.0.4
StringMapString converts a book record to map[string]string.
type BookDecoder ¶ added in v0.0.11
BookDecoder takes a io.Writer and returns a type that can Decode a book.
func DecodeJSON ¶ added in v0.0.11
func DecodeJSON(s *Serializer) BookDecoder
DecodeJSON configures a JSON BookDecoder.
func DecodeTOML ¶ added in v0.0.11
func DecodeTOML(s *Serializer) BookDecoder
DecodeTOML configures a TOML BookDecoder.
func DecodeYAML ¶ added in v0.0.11
func DecodeYAML(s *Serializer) BookDecoder
DecodeYAML configures a YAML BookDecoder.
type BookEncoder ¶ added in v0.0.11
BookEncoder takes a io.Writer and returns a type that can Encode a book.
func EncodeJSON ¶ added in v0.0.11
func EncodeJSON(s *Serializer) BookEncoder
EncodeJSON configures a JSON BookEncoder.
func EncodeTOML ¶ added in v0.0.11
func EncodeTOML(s *Serializer) BookEncoder
EncodeTOML configures a TOML BookEncoder.
func EncodeYAML ¶ added in v0.0.11
func EncodeYAML(s *Serializer) BookEncoder
EncodeYAML configures a YAML BookEncoder.
type CmdOpt ¶
type CmdOpt func(*Command)
CmdOpt sets options for the calibredb command.
func Authenticate ¶
Authenticate is used to pass credentials to the calibre content server.
type Command ¶
type Command struct { CdbCmd string // contains filtered or unexported fields }
Command represents a calibredb command.
func (*Command) AddFormat ¶
AddFormat initializes the add_format command with the id string, file string paramaters.
func (*Command) EmbedMetadata ¶
func (c *Command) EmbedMetadata() *EmbedMetadata
EmbedMetadata initializes the embed_metadata command.
func (*Command) RemoveFormat ¶
func (c *Command) RemoveFormat(id string, fmt string) *RemoveFormat
RemoveFormat initializes the remove_format command with the id string, fmt string paramaters.
func (*Command) SavedSearchesAdd ¶
func (c *Command) SavedSearchesAdd(name string, expression string) *SavedSearchesAdd
SavedSearchesAdd initializes the saved_searches add command with the name string, expression string paramaters.
func (*Command) SavedSearchesList ¶
func (c *Command) SavedSearchesList() *SavedSearchesList
SavedSearchesList initializes the saved_searches list command.
func (*Command) SavedSearchesRemove ¶
func (c *Command) SavedSearchesRemove(name string) *SavedSearchesRemove
SavedSearchesRemove initializes the saved_searches remove command with the name string paramaters.
func (*Command) SetMetadata ¶
func (c *Command) SetMetadata(id string) *SetMetadata
SetMetadata initializes the set_metadata command with the id string paramaters.
func (*Command) ShowMetadata ¶
func (c *Command) ShowMetadata(id string) *ShowMetadata
ShowMetadata initializes the show_metadata command with the id string paramaters.
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB holds the database connection.
func (DB) IsConnected ¶
IsConnected checks if the database is connected.
type DecoderInit ¶ added in v0.0.11
type DecoderInit func(*Serializer) BookDecoder
DecoderInit takes the serializer options and returns a function that initializes a Decoder.
type EditableFields ¶ added in v0.0.11
type EditableFields struct { Title string `db:"title" yaml:"title" toml:"title" json:"title"` Authors []string `db:"authors" yaml:"authors,omitempty" toml:"authors,omitempty" json:"authors,omitempty"` Narrators []string `db:"narrators" yaml:"narrators,omitempty" toml:"narrators,omitempty" json:"narrators,omitempty"` Series string `db:"series" yaml:"series,omitempty" toml:"series,omitempty" json:"series,omitempty"` SeriesIndex float64 `` /* 145-byte string literal not displayed */ Tags []string `db:"tags" yaml:"tags,omitempty" toml:"tags,omitempty" json:"tags,omitempty"` Pubdate time.Time `db:"pubdate" yaml:"pubdate,omitempty" toml:"pubdate,omitempty" json:"pubdate,omitempty"` Duration string `db:"duration" yaml:"duration,omitempty" toml:"duration,omitempty" json:"duration,omitempty"` Comments string `db:"comments" yaml:"comments,omitempty" toml:"comments,omitempty" json:"comments,omitempty"` Rating int `db:"rating" yaml:"rating,omitempty" toml:"rating,omitempty" json:"rating,omitempty"` Publisher string `db:"publisher" yaml:"publisher,omitempty" toml:"publisher,omitempty" json:"publisher,omitempty"` Languages []string `db:"languages" yaml:"languages,omitempty" toml:"languages,omitempty" json:"languages,omitempty"` Identifiers []string `db:"identifiers" yaml:"identifiers,omitempty" toml:"identifiers,omitempty" json:"identifiers,omitempty"` AuthorSort string `` /* 140-byte string literal not displayed */ Sort string `db:"sort" yaml:"sort,omitempty" toml:"sort,omitempty" json:"sort,omitempty"` }
EditableFields are fields that can be set with the calibredb set_metadata command.
type EmbedMetadata ¶
type EmbedMetadata struct {
*Command
}
EmbedMetadata represents 'calibredb embed_metadata'.
func (*EmbedMetadata) OnlyFormats ¶
func (c *EmbedMetadata) OnlyFormats() *EmbedMetadata
OnlyFormats sets the --only_formats flag for 'calibredb embed_metadata'.
type EncoderInit ¶ added in v0.0.11
type EncoderInit func(*Serializer) BookEncoder
EncoderInit takes the serializer options and returns a function that initializes an Encoder.
type Export ¶
type Export struct {
*Command
}
Export represents 'calibredb export'.
func (*Export) DontAsciiize ¶
DontAsciiize sets the --dont_asciiize flag for 'calibredb export'.
func (*Export) DontSaveCover ¶
DontSaveCover sets the --dont_save_cover flag for 'calibredb export'.
func (*Export) DontUpdateMetadata ¶
DontUpdateMetadata sets the --dont_update_metadata flag for 'calibredb export'.
func (*Export) DontWriteOpf ¶
DontWriteOpf sets the --dont_write_opf flag for 'calibredb export'.
func (*Export) ReplaceWhitespace ¶
ReplaceWhitespace sets the --replace_whitespace flag for 'calibredb export'.
func (*Export) ToLowercase ¶
ToLowercase sets the --to_lowercase flag for 'calibredb export'.
type Lib ¶
type Lib struct { *DB Name string Path string IsAudiobooks bool // contains filtered or unexported fields }
Lib represents a calibre library.
func (*Lib) GetBooks ¶
GetBooks runs a database query. Takes an squirrel.Sqlizer interface to generate the sql.
func (*Lib) GetPreference ¶
GetPreference gets a calibre preference.
type Model ¶
type Model struct { CategorySort string `yaml:"category_sort" db:"category_sort"` Column string `yaml:"column" db:"column"` Colnum int `yaml:"colnum" db:"id"` IsCategory bool `yaml:"is_category" db:"is_category"` IsCustom bool `yaml:"is_custom" db:"is_custom"` IsEditable bool `yaml:"is_editable" db:"is_editable"` IsNames bool `yaml:"is_names" db:"is_names"` JoinTable string `yaml:"join_table" db:"join_table"` Label string `yaml:"label" db:"label"` LinkColumn string `yaml:"link_column" db:"link_column"` Name string `yaml:"name" db:"name"` Table string `yaml:"table" db:"table"` }
Model represents a book field.
type Models ¶
Models is a map of Model.
func AudiobookModels ¶
func AudiobookModels() Models
AudiobookModels returns the default book fields with Duration and Narrators.
type Option ¶
type Option func(*Lib)
Option is a set a library option.
func IsAudiobooks ¶
func IsAudiobooks() Option
IsAudiobooks marks a library as containing audiobooks.
func PrintQuery ¶ added in v0.0.4
func PrintQuery() Option
PrintQuery prints the database query to stdout.
type Query ¶
type Query struct {
// contains filtered or unexported fields
}
Query represents a database query.
type Records ¶ added in v0.0.4
type Records struct {
// contains filtered or unexported fields
}
func (Records) MarshalJSON ¶ added in v0.0.4
func (Records) StringMapString ¶ added in v0.0.4
func (Records) UnmarshalJSON ¶ added in v0.0.4
type RemoveFormat ¶
type RemoveFormat struct {
*Command
}
RemoveFormat represents 'calibredb remove_format'.
type SavedSearchesAdd ¶
type SavedSearchesAdd struct {
*Command
}
SavedSearchesAdd represents 'calibredb saved_searches add'.
type SavedSearchesList ¶
type SavedSearchesList struct {
*Command
}
SavedSearchesList represents 'calibredb saved_searches list'.
type SavedSearchesRemove ¶
type SavedSearchesRemove struct {
*Command
}
SavedSearchesRemove represents 'calibredb saved_searches remove'.
type Serializer ¶ added in v0.0.11
type Serializer struct { Indent int Format string Editable bool Book *Book // contains filtered or unexported fields }
Serializer holds the options for encoding or decoding a book.
func NewSerializer ¶ added in v0.0.11
func NewSerializer(b *Book, opts ...SerializerOpt) *Serializer
NewSerializer constructs a serializer for a book with default options.
func (*Serializer) Decoder ¶ added in v0.0.11
func (s *Serializer) Decoder(init DecoderInit) *Serializer
Decoder takes a DecoderInit and sets the BookDecoder.
func (*Serializer) Encoder ¶ added in v0.0.11
func (s *Serializer) Encoder(init EncoderInit) *Serializer
Encoder takes a EncoderInit and sets the BookEncoder.
func (*Serializer) ReadFile ¶ added in v0.0.11
func (s *Serializer) ReadFile(path string) error
ReadFile reads a file for decoding.
func (*Serializer) ReadFrom ¶ added in v0.0.11
func (s *Serializer) ReadFrom(r io.Reader) error
ReadFrom reads from io.Reader for decoding.
func (*Serializer) WriteFile ¶ added in v0.0.11
func (s *Serializer) WriteFile(name string) error
WriteFile writes an encoded book to disk.
type SerializerOpt ¶ added in v0.0.11
type SerializerOpt func(*Serializer)
SerializerOpt sets the options for a serializer.
func EditableOnly ¶ added in v0.0.11
func EditableOnly() SerializerOpt
EditableOnly sets the option for serializing only editable book fields.
func WithFormat ¶ added in v0.0.11
func WithFormat(ext string) SerializerOpt
WithFormat sets the encoding format extension.
func WithIndent ¶ added in v0.0.11
func WithIndent(n int) SerializerOpt
WithIndent sets the number of spaces for indenting.
type SetMetadata ¶
type SetMetadata struct {
*Command
}
SetMetadata represents 'calibredb set_metadata'.
func (*SetMetadata) Field ¶
func (c *SetMetadata) Field(v string) *SetMetadata
Field sets the --field [string] flag for 'calibredb set_metadata'.
func (*SetMetadata) ListFields ¶
func (c *SetMetadata) ListFields() *SetMetadata
ListFields sets the --list_fields flag for 'calibredb set_metadata'.
type ShowMetadata ¶
type ShowMetadata struct {
*Command
}
ShowMetadata represents 'calibredb show_metadata'.
func (*ShowMetadata) AsOpf ¶
func (c *ShowMetadata) AsOpf() *ShowMetadata
AsOpf sets the --as_opf flag for 'calibredb show_metadata'.