Documentation
¶
Index ¶
- func RegisterRoutes(g *echo.Group, db *bun.DB, authMiddleware *auth.Middleware, ...)
- func ShouldUpdateChapters(newChapters []mediafile.ParsedChapter, newSource string, ...) bool
- type ChapterInput
- type ReplaceChaptersPayload
- type Service
- func (svc *Service) DeleteChaptersForFile(ctx context.Context, fileID int) error
- func (svc *Service) ListChapters(ctx context.Context, fileID int) ([]*models.Chapter, error)
- func (svc *Service) ReplaceChapters(ctx context.Context, fileID int, chapters []mediafile.ParsedChapter) error
- func (svc *Service) ReplaceChaptersWithSource(ctx context.Context, fileID int, chapters []mediafile.ParsedChapter, ...) error
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 (*Service) DeleteChaptersForFile ¶
DeleteChaptersForFile deletes all chapters for a file.
func (*Service) ListChapters ¶
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.