Documentation
¶
Index ¶
- Constants
- func BookSidecarExists(bookPath string) bool
- func BookSidecarPath(bookPath string) string
- func ChaptersToModels(chapters []ChapterMetadata) []*models.Chapter
- func FileSidecarExists(filePath string) bool
- func FileSidecarPath(filePath string) string
- func WriteBookSidecar(bookPath string, s *BookSidecar) error
- func WriteBookSidecarFromModel(book *models.Book) error
- func WriteFileSidecar(filePath string, s *FileSidecar) error
- func WriteFileSidecarFromModel(file *models.File) error
- func WriteFileSidecarWithChapters(file *models.File, chapters []*models.Chapter) error
- type AuthorMetadata
- type BookSidecar
- type ChapterMetadata
- type FileSidecar
- type IdentifierMetadata
- type NarratorMetadata
- type SeriesMetadata
Constants ¶
const CurrentVersion = 1
CurrentVersion is the current version of the sidecar file format. Increment this when making breaking changes to the schema.
const SidecarSuffix = ".metadata.json"
Variables ¶
This section is empty.
Functions ¶
func BookSidecarExists ¶
BookSidecarExists checks if a book sidecar file exists.
func BookSidecarPath ¶
BookSidecarPath returns the sidecar file path for a book. For directory-based books: {bookdir}/{dirname}.metadata.json. For root-level books: {dir}/{filename_without_ext}.metadata.json.
func ChaptersToModels ¶
func ChaptersToModels(chapters []ChapterMetadata) []*models.Chapter
ChaptersToModels converts ChapterMetadata slice to model chapters. Note: This creates chapter models without IDs - they should be inserted fresh.
func FileSidecarExists ¶
FileSidecarExists checks if a file sidecar exists.
func FileSidecarPath ¶
FileSidecarPath returns the sidecar file path for a media file. Returns {filepath}.metadata.json.
func WriteBookSidecar ¶
func WriteBookSidecar(bookPath string, s *BookSidecar) error
WriteBookSidecar writes a book sidecar file. Note: The caller is responsible for ensuring the parent directory exists. For root-level files with OrganizeFileStructure enabled, the directory should be created before calling this function.
func WriteBookSidecarFromModel ¶
WriteBookSidecarFromModel writes a book sidecar from a Book model.
func WriteFileSidecar ¶
func WriteFileSidecar(filePath string, s *FileSidecar) error
WriteFileSidecar writes a file sidecar.
func WriteFileSidecarFromModel ¶
WriteFileSidecarFromModel writes a file sidecar from a File model.
Types ¶
type AuthorMetadata ¶
type AuthorMetadata struct {
Name string `json:"name"`
SortName string `json:"sort_name,omitempty"`
SortOrder int `json:"sort_order,omitempty"`
Role *string `json:"role,omitempty"` // CBZ creator role: writer, penciller, inker, etc.
}
AuthorMetadata represents an author in the sidecar file.
type BookSidecar ¶
type BookSidecar struct {
Version int `json:"version"`
Title string `json:"title,omitempty"`
SortTitle string `json:"sort_title,omitempty"`
Subtitle *string `json:"subtitle,omitempty"`
Description *string `json:"description,omitempty"`
Authors []AuthorMetadata `json:"authors,omitempty"`
Series []SeriesMetadata `json:"series,omitempty"`
Genres []string `json:"genres,omitempty"`
Tags []string `json:"tags,omitempty"`
}
BookSidecar represents the metadata sidecar for a book. This is stored as {bookname}.metadata.json in the book directory.
func BookSidecarFromModel ¶
func BookSidecarFromModel(book *models.Book) *BookSidecar
BookSidecarFromModel creates a BookSidecar from a Book model.
func ReadBookSidecar ¶
func ReadBookSidecar(bookPath string) (*BookSidecar, error)
ReadBookSidecar reads and parses a book sidecar file. Returns nil, nil if the sidecar doesn't exist.
type ChapterMetadata ¶
type ChapterMetadata struct {
Title string `json:"title"`
StartPage *int `json:"start_page,omitempty"`
StartTimestampMs *int64 `json:"start_timestamp_ms,omitempty"`
Href *string `json:"href,omitempty"`
Children []ChapterMetadata `json:"children,omitempty"`
}
ChapterMetadata represents a chapter in the sidecar file. Position fields are mutually exclusive based on file type: - CBZ uses StartPage (0-indexed). - M4B uses StartTimestampMs. - EPUB uses Href.
func ChaptersFromModels ¶
func ChaptersFromModels(chapters []*models.Chapter) []ChapterMetadata
ChaptersFromModels converts model chapters to ChapterMetadata slice.
type FileSidecar ¶
type FileSidecar struct {
Version int `json:"version"`
Narrators []NarratorMetadata `json:"narrators,omitempty"`
URL *string `json:"url,omitempty"`
Publisher *string `json:"publisher,omitempty"`
Imprint *string `json:"imprint,omitempty"`
ReleaseDate *string `json:"release_date,omitempty"` // ISO 8601 date string (YYYY-MM-DD)
Identifiers []IdentifierMetadata `json:"identifiers,omitempty"`
Name *string `json:"name,omitempty"`
Chapters []ChapterMetadata `json:"chapters,omitempty"`
CoverPage *int `json:"cover_page,omitempty"` // 0-indexed page number for CBZ cover
}
FileSidecar represents the metadata sidecar for a media file. This is stored as {filename}.metadata.json alongside the media file.
func FileSidecarFromModel ¶
func FileSidecarFromModel(file *models.File) *FileSidecar
FileSidecarFromModel creates a FileSidecar from a File model.
func ReadFileSidecar ¶
func ReadFileSidecar(filePath string) (*FileSidecar, error)
ReadFileSidecar reads and parses a file sidecar. Returns nil, nil if the sidecar doesn't exist.
type IdentifierMetadata ¶
type IdentifierMetadata struct {
Type string `json:"type"` // isbn_10, isbn_13, asin, uuid, goodreads, google, other
Value string `json:"value"`
}
IdentifierMetadata represents an identifier in the sidecar file.
type NarratorMetadata ¶
type NarratorMetadata struct {
Name string `json:"name"`
SortName string `json:"sort_name,omitempty"`
SortOrder int `json:"sort_order,omitempty"`
}
NarratorMetadata represents a narrator in the sidecar file.