filegen

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrKepubNotSupported = errors.New("KePub conversion not supported for this file type")

ErrKepubNotSupported is returned when KePub conversion is not supported for a file type.

View Source
var ErrNotImplemented = errors.New("file type generation not yet implemented")

ErrNotImplemented is returned when a file type generator is not yet implemented.

Functions

func SupportsKepub

func SupportsKepub(fileType string) bool

SupportsKepub returns true if the file type can be converted to KePub format.

Types

type CBZGenerator

type CBZGenerator struct{}

CBZGenerator generates CBZ comic book files with modified metadata.

func (*CBZGenerator) Generate

func (g *CBZGenerator) Generate(ctx context.Context, srcPath, destPath string, book *models.Book, file *models.File) error

Generate creates a modified CBZ at destPath with updated metadata. Images are processed to optimize for e-readers (resized, grayscale optimization).

func (*CBZGenerator) SupportedType

func (g *CBZGenerator) SupportedType() string

SupportedType returns the file type this generator handles.

type EPUBGenerator

type EPUBGenerator struct{}

EPUBGenerator generates EPUB files with modified metadata.

func (*EPUBGenerator) Generate

func (g *EPUBGenerator) Generate(ctx context.Context, srcPath, destPath string, book *models.Book, file *models.File) error

Generate creates a modified EPUB at destPath with updated metadata.

func (*EPUBGenerator) SupportedType

func (g *EPUBGenerator) SupportedType() string

SupportedType returns the file type this generator handles.

type GenerationError

type GenerationError struct {
	FileType string
	Err      error
	Message  string
}

GenerationError represents an error that occurred during file generation.

func NewGenerationError

func NewGenerationError(fileType string, err error, message string) *GenerationError

NewGenerationError creates a new GenerationError.

func (*GenerationError) Error

func (e *GenerationError) Error() string

func (*GenerationError) Unwrap

func (e *GenerationError) Unwrap() error

type Generator

type Generator interface {
	// Generate creates a modified file at destPath from the source file.
	Generate(ctx context.Context, srcPath, destPath string, book *models.Book, file *models.File) error

	// SupportedType returns the file type this generator handles.
	SupportedType() string
}

Generator defines the interface for file generation.

func GetGenerator

func GetGenerator(fileType string) (Generator, error)

GetGenerator returns the appropriate generator for a file type.

func GetKepubGenerator

func GetKepubGenerator(fileType string) (Generator, error)

GetKepubGenerator returns the appropriate KePub generator for a file type. Returns ErrKepubNotSupported for file types that don't support KePub conversion (M4B).

type KepubCBZGenerator

type KepubCBZGenerator struct {
	// contains filtered or unexported fields
}

KepubCBZGenerator generates KePub files from CBZ sources. It converts CBZ comic archives to fixed-layout EPUBs with KePub enhancements.

func NewKepubCBZGenerator

func NewKepubCBZGenerator() *KepubCBZGenerator

NewKepubCBZGenerator creates a new KepubCBZGenerator.

func (*KepubCBZGenerator) Generate

func (g *KepubCBZGenerator) Generate(ctx context.Context, srcPath, destPath string, book *models.Book, file *models.File) error

Generate creates a KePub file at destPath from a CBZ source. The CBZ is converted to a fixed-layout EPUB with KePub enhancements. Images are copied byte-for-byte without modification (lossless).

func (*KepubCBZGenerator) SupportedType

func (g *KepubCBZGenerator) SupportedType() string

SupportedType returns the file type this generator handles.

type KepubEPUBGenerator

type KepubEPUBGenerator struct {
	// contains filtered or unexported fields
}

KepubEPUBGenerator generates KePub files from EPUB sources.

func NewKepubEPUBGenerator

func NewKepubEPUBGenerator() *KepubEPUBGenerator

NewKepubEPUBGenerator creates a new KepubEPUBGenerator.

func (*KepubEPUBGenerator) Generate

func (g *KepubEPUBGenerator) Generate(ctx context.Context, srcPath, destPath string, book *models.Book, file *models.File) error

Generate creates a KePub file at destPath from an EPUB source. It first generates an EPUB with updated metadata, then converts it to KePub.

func (*KepubEPUBGenerator) SupportedType

func (g *KepubEPUBGenerator) SupportedType() string

SupportedType returns the file type this generator handles.

type M4BGenerator

type M4BGenerator struct{}

M4BGenerator generates M4B audiobook files with modified metadata.

func (*M4BGenerator) Generate

func (g *M4BGenerator) Generate(ctx context.Context, srcPath, destPath string, book *models.Book, file *models.File) error

Generate creates a modified M4B at destPath with updated metadata.

func (*M4BGenerator) SupportedType

func (g *M4BGenerator) SupportedType() string

SupportedType returns the file type this generator handles.

Jump to

Keyboard shortcuts

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