epubparser

package module
v0.0.0-...-e11130f Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2026 License: MIT Imports: 10 Imported by: 0

README

epubparser

Personal go package for extracting metadata from my .epub books downloaded from AO3

Documentation

Overview

Package epubparser provides functions for reading EPUB files and extracting basic metadata such as title, author, description and various tags. It is designed to be embedded in other applications (a CLI, a GUI, etc.) that need to index or display metadata from book files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractXmlFromZip

func ExtractXmlFromZip(path string, filenameSubstring string) (string, error)

func SaveBooks

func SaveBooks(jsonPath string, books []Book) error

Types

type Book

type Book struct {
	Title    string   `json:"title"`
	Metadata Metadata `json:"metadata"`
	Path     string   `json:"path"`
}

func ScanDirectory

func ScanDirectory(path string) ([]Book, error)

ScanDirectory walks the given path and returns a slice of Book objects for every ".epub" file found directly inside. Subdirectories are ignored.

type Metadata

type Metadata struct {
	Title           string   `json:"title"`
	Description     string   `json:"description"`
	Creators        string   `json:"creators"`
	Category        string   `json:"category"`
	AgeRating       string   `json:"age_rating"`
	ContentWarnings []string `json:"content_warnings"`
	Fandoms         []string `json:"fandoms"`
	Characters      []string `json:"characters"`
	Relationships   []string `json:"relationships"`
	AdditionalTags  []string `json:"additional_tags"`
}

func Parse

func Parse(path string) Metadata

Parse opens the EPUB file located at the supplied path, reads the embedded XML documents (in particular the package OPF and the first XHTML preface) and returns a Metadata struct populated with the information it finds. Any fatal errors during parsing will call log.Fatal; callers should normally validate the file before using this helper.

Jump to

Keyboard shortcuts

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