Documentation
¶
Overview ¶
Package library manages Prism library records and their disk-level stats.
Index ¶
- Variables
- func ParseQualityFromPath(path string) plugin.Quality
- type CreateRequest
- type DiskFile
- type DiskFileTMDBMatch
- type Library
- type Service
- func (s *Service) Create(ctx context.Context, req CreateRequest) (Library, error)
- func (s *Service) Delete(ctx context.Context, id string) error
- func (s *Service) DeleteCandidate(ctx context.Context, libraryID, filePath string) error
- func (s *Service) Get(ctx context.Context, id string) (Library, error)
- func (s *Service) List(ctx context.Context) ([]Library, error)
- func (s *Service) ListCandidates(ctx context.Context, libraryID string) ([]DiskFile, error)
- func (s *Service) Scan(ctx context.Context, libraryID string) error
- func (s *Service) ScanDisk(ctx context.Context, libraryID string) ([]DiskFile, error)
- func (s *Service) Stats(ctx context.Context, id string) (Stats, error)
- func (s *Service) Update(ctx context.Context, id string, req UpdateRequest) (Library, error)
- type Stats
- type UpdateRequest
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("library not found")
ErrNotFound is returned when a library does not exist.
Functions ¶
func ParseQualityFromPath ¶
ParseQualityFromPath infers video quality metadata from a file path using simple pattern matching. It is best-effort; fields that cannot be determined default to the "unknown" / "none" plugin constants.
Types ¶
type CreateRequest ¶
type CreateRequest struct {
Name string
RootPath string
DefaultQualityProfileID string
NamingFormat *string
MinFreeSpaceGB int
Tags []string
}
CreateRequest carries the fields needed to create a library.
type DiskFile ¶
type DiskFile struct {
Path string
SizeBytes int64
ParsedTitle string
ParsedYear int
TMDBMatch *DiskFileTMDBMatch // nil if not yet matched
}
DiskFile represents a video file found on disk during a library scan.
type DiskFileTMDBMatch ¶
DiskFileTMDBMatch holds the pre-computed TMDB match for a DiskFile.
type Library ¶
type Library struct {
ID string
Name string
RootPath string
DefaultQualityProfileID string
NamingFormat *string
MinFreeSpaceGB int
Tags []string
CreatedAt time.Time
UpdatedAt time.Time
}
Library is the domain representation of a library record.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service manages library records.
func NewService ¶
NewService creates a new Service backed by the given querier, event bus, and optional TMDB searcher (pass nil to disable background candidate matching).
func (*Service) Delete ¶
Delete removes a library by ID. Returns ErrNotFound if the library does not exist.
func (*Service) DeleteCandidate ¶
DeleteCandidate removes a file from the candidate table after it has been imported. It is a best-effort call — errors are intentionally ignored.
func (*Service) Get ¶
Get returns a library by ID. Returns ErrNotFound if no library with that ID exists.
func (*Service) ListCandidates ¶
ListCandidates returns all file candidates for a library from the database without walking the disk. This is the fast path used by the import modal; callers that need a fresh disk walk should use ScanDisk instead.
func (*Service) Scan ¶
Scan walks a library's root path and reconciles tracked movie files against what is actually on disk:
- Files that exist → indexed_at is updated.
- Files that are missing → the owning movie is marked "missing".
Scan is idempotent and safe to run concurrently with normal operations.
func (*Service) ScanDisk ¶
ScanDisk walks the library's root path and returns video files that are not yet tracked in the movie_files table. It is the read-only counterpart to Scan — callers may use the result to let users select files for import.
As a side-effect, newly discovered files are upserted into library_file_candidates and a background TMDB matching pass is triggered for any unmatched candidates.
type Stats ¶
type Stats struct {
MovieCount int64
TotalSizeBytes int64
FreeSpaceBytes int64
HealthOK bool
HealthMessage string
}
Stats holds runtime metrics about a library's disk usage and health.
type UpdateRequest ¶
type UpdateRequest = CreateRequest
UpdateRequest carries the fields needed to update a library. It is identical in shape to CreateRequest.