chapters

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterRoutes

func RegisterRoutes(g *echo.Group, db *bun.DB, authMiddleware *auth.Middleware, bookService *books.Service)

RegisterRoutes registers chapter routes on the books group. bookService is required; pass a books service with app settings attached, or the replace handler's review recompute does nothing.

func ShouldUpdateChapters

func ShouldUpdateChapters(newChapters []mediafile.ParsedChapter, newSource string, existingSource *string, forceRefresh bool) bool

ShouldUpdateChapters determines if chapters should be updated based on priority rules. Returns true if the new chapters should replace existing ones.

When forceRefresh is true, sidecar-sourced chapters are skipped so that the embedded file metadata wins — matching the convention used by shouldApplySidecarScalar / shouldApplySidecarRelationship in pkg/worker. All non-sidecar sources still apply unconditionally under forceRefresh.

Types

type ChapterInput

type ChapterInput struct {
	Title            string         `json:"title"`
	StartPage        *int           `json:"start_page"`
	StartTimestampMs *int64         `json:"start_timestamp_ms"`
	Href             *string        `json:"href"`
	Children         []ChapterInput `json:"children"`
}

ChapterInput represents a chapter in API requests.

type ReplaceChaptersPayload

type ReplaceChaptersPayload struct {
	Chapters []ChapterInput `json:"chapters"`
}

ReplaceChaptersPayload is the request body for replacing chapters.

type Service

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

func NewService

func NewService(db *bun.DB) *Service

func (*Service) DeleteChaptersForFile

func (svc *Service) DeleteChaptersForFile(ctx context.Context, fileID int) error

DeleteChaptersForFile deletes all chapters for a file.

func (*Service) ListChapters

func (svc *Service) ListChapters(ctx context.Context, fileID int) ([]*models.Chapter, error)

ListChapters retrieves all chapters for a file, building nested structure.

func (*Service) ReplaceChapters

func (svc *Service) ReplaceChapters(ctx context.Context, fileID int, chapters []mediafile.ParsedChapter) error

ReplaceChapters deletes all existing chapters for a file and inserts new ones.

func (*Service) ReplaceChaptersWithSource added in v0.2.0

func (svc *Service) ReplaceChaptersWithSource(ctx context.Context, fileID int, chapters []mediafile.ParsedChapter, source string) error

ReplaceChaptersWithSource replaces a file's chapters and records their source in one transaction, so the chapters are never stored under a source that would let a scan replace them.

Jump to

Keyboard shortcuts

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