database

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Overview

Package database provides SQLite and Postgres-protocol access for outtake.

Index

Constants

View Source
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

View Source
var ErrClipNotFound = errors.New("clip not found")

ErrClipNotFound is returned when a clip row does not exist.

View Source
var ErrClipProfileNotFound = errors.New("clip profile not found")

ErrClipProfileNotFound is returned when a clip profile row does not exist.

View Source
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 New

func New(dbPath string) (*DB, error)

New creates a new SQLite database instance.

func NewFromConfig

func NewFromConfig(cfg *config.Config) (*DB, error)

NewFromConfig constructs the database backend selected by configuration.

func (*DB) ClearAuth

func (db *DB) ClearAuth(ctx context.Context) error

ClearAuth deletes stored Plex tokens and the selected server.

func (*DB) Close

func (db *DB) Close() error

Close closes the database connection.

func (*DB) Conn

func (db *DB) Conn() *sql.DB

Conn returns the underlying database connection.

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

func (db *DB) DeleteClip(ctx context.Context, id string) error

DeleteClip removes a clip row.

func (*DB) DeleteClipProfile

func (db *DB) DeleteClipProfile(ctx context.Context, id string) error

DeleteClipProfile removes a profile and keeps a default assigned.

func (*DB) GetClip

func (db *DB) GetClip(ctx context.Context, id string) (*queue.Job, error)

GetClip loads a clip by ID.

func (*DB) GetClipProfile

func (db *DB) GetClipProfile(ctx context.Context, id string) (ClipProfile, error)

GetClipProfile loads a clip profile by ID.

func (*DB) LatestToken

func (db *DB) LatestToken(ctx context.Context) (string, error)

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) ListClips

func (db *DB) ListClips(ctx context.Context) ([]*queue.Job, error)

ListClips returns all clips ordered by creation time, newest first.

func (*DB) ListClipsForMedia

func (db *DB) ListClipsForMedia(ctx context.Context, mediaID string) ([]*queue.Job, error)

ListClipsForMedia returns clips created from a media item.

func (*DB) ListPendingClips

func (db *DB) ListPendingClips(ctx context.Context) ([]*queue.Job, error)

ListPendingClips returns clips that still need processing.

func (*DB) SaveClip

func (db *DB) SaveClip(ctx context.Context, job *queue.Job) error

SaveClip inserts or replaces a clip job.

func (*DB) SaveClipProfile

func (db *DB) SaveClipProfile(ctx context.Context, profile ClipProfile) error

SaveClipProfile inserts or replaces a clip profile.

func (*DB) SaveSelectedServer

func (db *DB) SaveSelectedServer(ctx context.Context, server plex.Server) error

SaveSelectedServer upserts the single selected Plex server.

func (*DB) SaveToken

func (db *DB) SaveToken(ctx context.Context, clientID, accessToken string) error

SaveToken stores the Plex access token for a client ID.

func (*DB) SelectedServer

func (db *DB) SelectedServer(ctx context.Context) (plex.Server, bool, error)

SelectedServer loads the persisted Plex server, if any.

func (*DB) SetDefaultClipProfile

func (db *DB) SetDefaultClipProfile(ctx context.Context, id string) error

SetDefaultClipProfile marks one profile as the default.

type Scannable

type Scannable interface {
	Scan(dest ...any) error
}

Scannable is implemented by sql.Row and sql.Rows.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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