importer

package
v0.0.0-...-a0c8092 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildAudiobookTracks

func BuildAudiobookTracks(destPath string) ([]domain.Track, int, error)

BuildAudiobookTracks enumerates audio files and creates a track list.

func ContainsAudioFiles

func ContainsAudioFiles(dirPath string) bool

ContainsAudioFiles returns true if the directory contains audio files.

func ExtractEpubAsset

func ExtractEpubAsset(filePath string, assetPath string) ([]byte, error)

ExtractEpubAsset returns raw bytes for an asset within an EPUB.

func ExtractMobiTextPreview

func ExtractMobiTextPreview(filePath string, maxChars int) (string, error)

ExtractMobiTextPreview returns a plain-text preview of MOBI content.

func ExtractTextPreview

func ExtractTextPreview(filePath string, maxChars int) (string, error)

ExtractTextPreview returns a plain-text preview of a book's content.

func InferEditionType

func InferEditionType(filePath string) string

InferEditionType determines the edition type from a file path.

func InferFormat

func InferFormat(filePath string) string

InferFormat determines the format string from a file path.

func IsAudioExt

func IsAudioExt(path string) bool

IsAudioExt returns true if the file extension is a supported audio format.

func IsImportableExt

func IsImportableExt(path string) bool

IsImportableExt returns true if the file extension is importable.

Types

type Extracted

type Extracted struct {
	Title         string
	Authors       []string
	Series        string
	SeriesIndex   float64
	ISBN          string
	PublishedYear int
	Language      string
	Publisher     string
	Description   string
	Subjects      []string // genre/category tags
	Format        string   // "epub", "mobi", "mp3", "m4b", "pdf"
	CoverData     []byte
	CoverExt      string // ".jpg", ".png", etc.
}

Extracted holds metadata extracted from a book file.

func ExtractAudioMetadata

func ExtractAudioMetadata(filePath string) (*Extracted, error)

ExtractAudioMetadata extracts metadata from an audio file or directory.

func ExtractEpubMetadata

func ExtractEpubMetadata(filePath string) (*Extracted, error)

ExtractEpubMetadata extracts metadata and cover from an EPUB file.

func ExtractMobiMetadata

func ExtractMobiMetadata(filePath string) (*Extracted, error)

ExtractMobiMetadata extracts metadata and cover from a MOBI file.

type ImportInput

type ImportInput struct {
	SourcePath  string
	LibraryID   int64
	Title       string
	Authors     []string
	Series      string
	SeriesIndex *float64
}

ImportInput specifies what to import.

type ImportResult

type ImportResult struct {
	Work       *domain.Work
	Edition    *domain.Edition
	IsNew      bool
	Skipped    bool
	SkipReason string
}

ImportResult describes the outcome of an import.

type Importer

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

Importer orchestrates the full import pipeline.

func NewImporter

func NewImporter(s store.Store, dataDir string) *Importer

NewImporter creates a new Importer.

func (*Importer) BulkImport

func (imp *Importer) BulkImport(dirPath string, libraryID int64) ([]ImportResult, error)

BulkImport imports all supported files from a directory.

func (*Importer) Import

func (imp *Importer) Import(input ImportInput) (*ImportResult, error)

Import imports a single file or directory.

type MatchResult

type MatchResult struct {
	Work               *domain.Work
	Authors            []domain.Author
	Series             *domain.Series
	IsNewWork          bool
	IsDuplicate        bool
	DuplicateEditionID int64
}

MatchResult contains the results of matching extracted metadata against the store.

type Matcher

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

Matcher matches extracted metadata to existing or new entities in the store.

func NewMatcher

func NewMatcher(s store.Store) *Matcher

NewMatcher creates a new Matcher.

func (*Matcher) Match

func (m *Matcher) Match(meta *Extracted, libraryID int64, fileHash string) (*MatchResult, error)

Match takes extracted metadata and finds or creates the corresponding Work, Authors, and Series.

type ReaderChapter

type ReaderChapter struct {
	Index int
	Title string
}

ReaderChapter describes a chapter in an EPUB for the reader.

func ExtractEpubChapter

func ExtractEpubChapter(filePath string, index int) (string, string, []ReaderChapter, error)

ExtractEpubChapter returns chapter HTML, the chapter file path within the EPUB, and the full chapter list.

func ExtractEpubChapterText

func ExtractEpubChapterText(filePath string, index int) (string, []ReaderChapter, error)

ExtractEpubChapterText returns plain text for an EPUB chapter.

Jump to

Keyboard shortcuts

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