Documentation
¶
Overview ¶
Package collection manages director/actor filmography collections.
Index ¶
- Variables
- type AddMissingRequest
- type AddMissingResult
- type AddSelectedRequest
- type Collection
- type EntitySearchResult
- type Item
- type MetadataProvider
- type Service
- func (s *Service) AddMissing(ctx context.Context, id string, req AddMissingRequest) (AddMissingResult, error)
- func (s *Service) AddSelected(ctx context.Context, id string, req AddSelectedRequest) (AddMissingResult, error)
- func (s *Service) Create(ctx context.Context, personID int, personType string) (*Collection, error)
- func (s *Service) Delete(ctx context.Context, id string) error
- func (s *Service) Get(ctx context.Context, id string) (*Collection, error)
- func (s *Service) List(ctx context.Context) ([]Collection, error)
- func (s *Service) SearchAll(ctx context.Context, query string) ([]EntitySearchResult, error)
- func (s *Service) SearchPeople(ctx context.Context, query string) ([]tmdb.PersonSearchResult, error)
Constants ¶
This section is empty.
Variables ¶
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 ¶
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 ¶
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 ¶
Delete removes a collection record. Returns ErrNotFound if it does not exist.
func (*Service) Get ¶
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 ¶
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.