collection

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package collection manages director/actor filmography collections.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound      = errors.New("collection not found")
	ErrAlreadyExists = errors.New("collection already exists for this person")
)

Sentinel errors.

Functions

This section is empty.

Types

type AddMissingRequest

type AddMissingRequest struct {
	LibraryID           string
	QualityProfileID    string
	MinimumAvailability string
}

AddMissingRequest carries settings for adding all missing films at once.

type AddMissingResult

type AddMissingResult struct {
	Added             int
	SkippedDuplicates int
}

AddMissingResult summarises what happened.

type AddSelectedRequest

type AddSelectedRequest struct {
	TMDBIDs             []int
	LibraryID           string
	QualityProfileID    string
	MinimumAvailability string
}

AddSelectedRequest carries settings for adding a specific set of films.

type Collection

type Collection struct {
	ID         string
	Name       string
	PersonID   int
	PersonType string
	CreatedAt  time.Time
	Items      []Item // nil on List; populated on Get
	Total      int
	InLibrary  int
	Missing    int
}

Collection is the full view of a collection record.

type EntitySearchResult

type EntitySearchResult struct {
	ID         int // TMDB ID
	Name       string
	ImagePath  string // profile_path for persons, poster_path for franchises
	Subtitle   string // known_for_department for persons, "Movie franchise" for franchises
	ResultType string // "person" | "franchise"
}

EntitySearchResult is a unified result from searching both people and franchises.

type Item

type Item struct {
	TMDBID     int
	Title      string
	Year       int
	PosterPath string
	InLibrary  bool
	HasFile    bool   // set when InLibrary=true and a movie file exists on disk
	MovieID    string // set when InLibrary=true
	Monitored  bool   // set when InLibrary=true
}

Item is one film in a person's filmography.

type MetadataProvider

type MetadataProvider interface {
	GetPerson(ctx context.Context, personID int) (*tmdb.Person, error)
	GetPersonFilmography(ctx context.Context, personID int, personType string) ([]tmdb.FilmographyItem, error)
	SearchPeople(ctx context.Context, query string) ([]tmdb.PersonSearchResult, error)
	SearchFranchises(ctx context.Context, query string) ([]tmdb.FranchiseSearchResult, error)
	GetFranchise(ctx context.Context, collectionID int) (*tmdb.FranchiseDetail, error)
}

MetadataProvider is the subset of the TMDB client needed by this package.

type Service

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

Service manages collection records.

func NewService

func NewService(q dbgen.Querier, provider MetadataProvider, movieSvc *movie.Service, logger *slog.Logger) *Service

NewService creates a new Service. provider may be nil when TMDB is not configured; Create and SearchPeople will return an error in that case.

func (*Service) AddMissing

func (s *Service) AddMissing(ctx context.Context, id string, req AddMissingRequest) (AddMissingResult, error)

AddMissing adds all films in the collection that are not yet in the library.

func (*Service) AddSelected

func (s *Service) AddSelected(ctx context.Context, id string, req AddSelectedRequest) (AddMissingResult, error)

AddSelected adds a specific set of films (by TMDB ID) to the library.

func (*Service) Create

func (s *Service) Create(ctx context.Context, personID int, personType string) (*Collection, error)

Create fetches the person's name from TMDB and inserts a collection record. Returns ErrAlreadyExists if a collection for that person+type already exists. After inserting, a background goroutine scans the current library for matches and stores the initial counts.

func (*Service) Delete

func (s *Service) Delete(ctx context.Context, id string) error

Delete removes a collection record. Returns ErrNotFound if it does not exist.

func (*Service) Get

func (s *Service) Get(ctx context.Context, id string) (*Collection, error)

Get returns a collection with its full item list fetched live from TMDB. As a side effect it refreshes the stored counts on the collection row.

func (*Service) List

func (s *Service) List(ctx context.Context) ([]Collection, error)

List returns all collections without item lists. Counts are read from stored values populated by the background scan on Create (or refreshed by Get).

func (*Service) SearchAll

func (s *Service) SearchAll(ctx context.Context, query string) ([]EntitySearchResult, error)

SearchAll searches TMDB for both people and movie franchises, returning a unified list (people first, then franchises).

func (*Service) SearchPeople

func (s *Service) SearchPeople(ctx context.Context, query string) ([]tmdb.PersonSearchResult, error)

SearchPeople searches TMDB for people by name.

Jump to

Keyboard shortcuts

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