Documentation
¶
Overview ¶
Package database provides SQLite and Postgres-protocol access for outtake.
Index ¶
- Constants
- Variables
- type ClipProfile
- type DB
- func (db *DB) ClearAuth(ctx context.Context) error
- func (db *DB) Close() error
- func (db *DB) Conn() *sql.DB
- func (db *DB) DefaultClipProfile(ctx context.Context) (ClipProfile, error)
- func (db *DB) DeleteClip(ctx context.Context, id string) error
- func (db *DB) DeleteClipProfile(ctx context.Context, id string) error
- func (db *DB) GetClip(ctx context.Context, id string) (*queue.Job, error)
- func (db *DB) GetClipProfile(ctx context.Context, id string) (ClipProfile, error)
- func (db *DB) LatestToken(ctx context.Context) (string, error)
- func (db *DB) ListClipProfiles(ctx context.Context) ([]ClipProfile, error)
- func (db *DB) ListClips(ctx context.Context) ([]*queue.Job, error)
- func (db *DB) ListClipsForMedia(ctx context.Context, mediaID string) ([]*queue.Job, error)
- func (db *DB) ListPendingClips(ctx context.Context) ([]*queue.Job, error)
- func (db *DB) SaveClip(ctx context.Context, job *queue.Job) error
- func (db *DB) SaveClipProfile(ctx context.Context, profile ClipProfile) error
- func (db *DB) SaveSelectedServer(ctx context.Context, server plex.Server) error
- func (db *DB) SaveToken(ctx context.Context, clientID, accessToken string) error
- func (db *DB) SelectedServer(ctx context.Context) (plex.Server, bool, error)
- func (db *DB) SetDefaultClipProfile(ctx context.Context, id string) error
- type Scannable
Constants ¶
const ( // BackendSQLite is the default libsql/SQLite backend. BackendSQLite = "sqlite" // BackendPostgres is the Postgres-protocol backend. BackendPostgres = "postgres" // BackendPgx is an alias for the Postgres-protocol backend. BackendPgx = "pgx" )
Variables ¶
var ErrClipNotFound = errors.New("clip not found")
ErrClipNotFound is returned when a clip row does not exist.
var ErrClipProfileNotFound = errors.New("clip profile not found")
ErrClipProfileNotFound is returned when a clip profile row does not exist.
var ErrLastClipProfile = errors.New("cannot delete the last clip profile")
ErrLastClipProfile is returned when deleting the only remaining profile.
Functions ¶
This section is empty.
Types ¶
type ClipProfile ¶
type ClipProfile struct {
ID string
Name string
CRF int
Preset string
AudioKbps int
MaxWidth int
IsDefault bool
CreatedAt time.Time
UpdatedAt time.Time
}
ClipProfile is a user-managed clip encode profile.
func (ClipProfile) QualityPreset ¶
func (profile ClipProfile) QualityPreset() media.QualityPreset
QualityPreset returns ffmpeg settings for a stored profile.
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB represents a database connection.
func NewFromConfig ¶
NewFromConfig constructs the database backend selected by configuration.
func (*DB) DefaultClipProfile ¶
func (db *DB) DefaultClipProfile(ctx context.Context) (ClipProfile, error)
DefaultClipProfile returns the profile marked default, or Medium built-in.
func (*DB) DeleteClip ¶
DeleteClip removes a clip row.
func (*DB) DeleteClipProfile ¶
DeleteClipProfile removes a profile and keeps a default assigned.
func (*DB) GetClipProfile ¶
GetClipProfile loads a clip profile by ID.
func (*DB) LatestToken ¶
LatestToken returns the most recently stored Plex token.
func (*DB) ListClipProfiles ¶
func (db *DB) ListClipProfiles(ctx context.Context) ([]ClipProfile, error)
ListClipProfiles returns clip profiles with the default first.
func (*DB) ListClipsForMedia ¶
ListClipsForMedia returns clips created from a media item.
func (*DB) ListPendingClips ¶
ListPendingClips returns clips that still need processing.
func (*DB) SaveClipProfile ¶
func (db *DB) SaveClipProfile(ctx context.Context, profile ClipProfile) error
SaveClipProfile inserts or replaces a clip profile.
func (*DB) SaveSelectedServer ¶
SaveSelectedServer upserts the single selected Plex server.
func (*DB) SelectedServer ¶
SelectedServer loads the persisted Plex server, if any.