commands

package
v0.0.39 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2026 License: BSD-3-Clause Imports: 45 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KiwixBin       = "kiwix-serve"
	KiwixPortStart = 8181
)
View Source
const HlsSegmentDuration = 10

Variables

View Source
var ErrUserQuit = errors.New("user requested quit")

ErrUserQuit is returned when the user chooses to quit during interactive decision.

View Source
var WaitForKiwixReady = DefaultWaitForKiwixReady
View Source
var ZimManager = &KiwixManager{
	Instances: make(map[string]*KiwixInstance),
	UsedPorts: make(map[int]bool),
}

Functions

func CastPlay

func CastPlay(ctx context.Context, flags models.GlobalFlags, media []models.MediaWithDB, audioOnly bool) error

func ClearQueryStats added in v0.0.34

func ClearQueryStats()

ClearQueryStats clears all recorded query statistics

func CopyMediaItem

func CopyMediaItem(destDir string, m models.MediaWithDB) error

func DefaultWaitForKiwixReady added in v0.0.38

func DefaultWaitForKiwixReady(ctx context.Context, port int, timeout time.Duration) error

func DeleteMediaItem

func DeleteMediaItem(m models.MediaWithDB) error

func DispatchPlaybackCommand added in v0.0.30

func DispatchPlaybackCommand(
	ctx context.Context,
	c models.ControlFlags,
	params PlaybackCommandParams,
) error

DispatchPlaybackCommand handles common logic for sending commands to mpv or Chromecast

func ExecutePostAction

func ExecutePostAction(ctx context.Context, flags models.GlobalFlags, media []models.MediaWithDB) error

ExecutePostAction executes actions after a command

func GetSchema

func GetSchema() string

GetSchema returns the database schema SQL

func HideRedundantFirstPlayed

func HideRedundantFirstPlayed(media []models.MediaWithDB)

func InteractiveDecision

func InteractiveDecision(ctx context.Context, flags models.GlobalFlags, m models.MediaWithDB) error

func IsPortAvailable added in v0.0.38

func IsPortAvailable(ctx context.Context, port int) bool

func IsQueryStatsEnabled added in v0.0.34

func IsQueryStatsEnabled() bool

IsQueryStatsEnabled returns true if query statistics collection is enabled

func MarkDeletedItem

func MarkDeletedItem(ctx context.Context, m models.MediaWithDB) error

func MoveMediaItem

func MoveMediaItem(ctx context.Context, destDir string, m models.MediaWithDB) error

func ParseDatabaseAndScanPaths added in v0.0.30

func ParseDatabaseAndScanPaths(
	args []string,
	coreFlags *models.CoreFlags,
	mediaFlags *models.MediaFilterFlags,
) (databases, scanPaths []string, err error)

ParseDatabaseAndScanPaths separates .db files from scan paths Returns databases, scan paths, and any error

func PrintFolders

func PrintFolders(flags models.DisplayFlags, columns []string, folders []models.FolderStats) error

func PrintFrequencyStats

func PrintFrequencyStats(stats []query.FrequencyStats) error

func PrintMedia

func PrintMedia(flags models.DisplayFlags, columns []string, media []models.MediaWithDB) error

func RecordSlowQuery added in v0.0.34

func RecordSlowQuery(query string, args []any, duration time.Duration, dbPath string, rowsAffected int64)

RecordSlowQuery records a slow query entry

func RunExitCommand

func RunExitCommand(ctx context.Context, flags models.GlobalFlags, exitCode int, path string) error

func RunQuery added in v0.0.30

func RunQuery(
	ctx context.Context,
	dbs []string,
	flags models.GlobalFlags,
	process func([]models.MediaWithDB) error,
) error

RunQuery handles the common boilerplate for executing a media query

func SchemaFS

func SchemaFS() embed.FS

SchemaFS provides access to the database schema

func SetQueryStatsEnabled added in v0.0.34

func SetQueryStatsEnabled(enabled bool)

SetQueryStatsEnabled enables or disables query statistics collection

func StartZimManager added in v0.0.38

func StartZimManager()

StartZimManager starts the ZIM manager's background cleanup goroutine. This should be called during application startup.

func TimedQuery added in v0.0.34

func TimedQuery[T any](_ context.Context, dbPath, query string, args []any, fn func() (T, error)) (T, error)

TimedQuery executes a query function and records timing if it exceeds the threshold

Types

type AddCmd

type AddCmd struct {
	models.CoreFlags        `embed:""`
	models.PathFilterFlags  `embed:""`
	models.FilterFlags      `embed:""`
	models.MediaFilterFlags `embed:""`

	Args                    []string `help:"Database file followed by paths to scan"                                  required:"true" name:"args" arg:""`
	Parallel                int      `help:"Number of parallel extractors (default: CPU count * 4)"                                                      short:"p"`
	ExtractText             bool     `help:"Extract full text from documents (PDF, EPUB, TXT, MD) for caption search"`
	OCR                     bool     `help:"Extract text from images using OCR (tesseract) for caption search"`
	OCREngine               string   `` /* 168-byte string literal not displayed */
	SpeechRecognition       bool     `help:"Extract speech-to-text from audio/video files for caption search"`
	SpeechRecognitionEngine string   `` /* 164-byte string literal not displayed */

	ScanPaths []string `kong:"-"`
	Database  string   `kong:"-"`
}

func (*AddCmd) AfterApply

func (c *AddCmd) AfterApply() error

func (*AddCmd) Run

func (c *AddCmd) Run(ctx context.Context) error

type BigDirsCmd

type BigDirsCmd struct {
	models.CoreFlags        `embed:""`
	models.PathFilterFlags  `embed:""`
	models.FilterFlags      `embed:""`
	models.MediaFilterFlags `embed:""`
	models.TimeFilterFlags  `embed:""`
	models.DeletedFlags     `embed:""`
	models.AggregateFlags   `embed:""`
	models.SortFlags        `embed:""`
	models.DisplayFlags     `embed:""`

	Databases []string `help:"SQLite database files" required:"true" arg:"" type:"existingfile"`
}

func (*BigDirsCmd) Run

func (c *BigDirsCmd) Run(ctx context.Context) error

type BrowseCmd

type BrowseCmd struct {
	models.CoreFlags        `embed:""`
	models.PathFilterFlags  `embed:""`
	models.FilterFlags      `embed:""`
	models.MediaFilterFlags `embed:""`
	models.SortFlags        `embed:""`

	Databases []string `help:"SQLite database files" required:"true" arg:"" type:"existingfile"`
	Browser   string   `help:"Browser to use"`
}

func (*BrowseCmd) Run

func (c *BrowseCmd) Run(ctx context.Context) error

type CaptionsQueryParams added in v0.0.38

type CaptionsQueryParams struct {
	QueryStr  string
	Limit     int64
	VideoOnly bool
	AudioOnly bool
	ImageOnly bool
	TextOnly  bool
}

CaptionsQueryParams contains the search query and filter options for caption retrieval

type CategorizeCmd

type CategorizeCmd struct {
	models.CoreFlags        `embed:""`
	models.QueryFlags       `embed:""`
	models.PathFilterFlags  `embed:""`
	models.FilterFlags      `embed:""`
	models.MediaFilterFlags `embed:""`
	models.TimeFilterFlags  `embed:""`
	models.DeletedFlags     `embed:""`
	models.PostActionFlags  `embed:""`

	Databases []string `help:"SQLite database files" required:"true" arg:"" type:"existingfile"`

	Other    bool `help:"Analyze 'other' category to find potential new categories"`
	FullPath bool `help:"Use full path for categorization suggestions instead of just filename"`
}

func (*CategorizeCmd) CompileRegexes

func (c *CategorizeCmd) CompileRegexes(ctx context.Context) map[string][]*regexp.Regexp

func (*CategorizeCmd) Run

func (c *CategorizeCmd) Run(ctx context.Context) error

type CheckCmd

type CheckCmd struct {
	models.CoreFlags        `embed:""`
	models.PathFilterFlags  `embed:""`
	models.MediaFilterFlags `embed:""`

	Args   []string `help:"Database file followed by optional paths to check" required:"true" arg:""`
	DryRun bool     `help:"Don't actually mark files as deleted"`

	CheckPaths []string `kong:"-"`
	Databases  []string `kong:"-"`
}

func (*CheckCmd) AfterApply

func (c *CheckCmd) AfterApply() error

func (*CheckCmd) Run

func (c *CheckCmd) Run(ctx context.Context) error

type ClusterSortCmd

type ClusterSortCmd struct {
	models.CoreFlags       `embed:""`
	models.SimilarityFlags `embed:""`
	models.TextFlags       `embed:""`

	InputPath  string `help:"Input file path (default stdin)"   default:"-" arg:"" optional:""`
	OutputPath string `help:"Output file path (default stdout)"`
}

func (*ClusterSortCmd) Run

func (c *ClusterSortCmd) Run(ctx context.Context) error

type DedupeCmd

type DedupeCmd struct {
	models.CoreFlags        `embed:""`
	models.PathFilterFlags  `embed:""`
	models.FilterFlags      `embed:""`
	models.MediaFilterFlags `embed:""`
	models.TimeFilterFlags  `embed:""`
	models.DeletedFlags     `embed:""`
	models.DedupeFlags      `embed:""`
	models.PostActionFlags  `embed:""`
	models.HashingFlags     `embed:""`

	Databases []string `help:"SQLite database files" required:"true" arg:"" type:"existingfile"`
}

func (*DedupeCmd) Run

func (c *DedupeCmd) Run(ctx context.Context) error

type DedupeDuplicate

type DedupeDuplicate struct {
	KeepPath      string
	DuplicatePath string
	DuplicateSize int64
}

type DiskUsageCmd

type DiskUsageCmd struct {
	models.CoreFlags        `embed:""`
	models.PathFilterFlags  `embed:""`
	models.FilterFlags      `embed:""`
	models.MediaFilterFlags `embed:""`
	models.TimeFilterFlags  `embed:""`
	models.DeletedFlags     `embed:""`
	models.SortFlags        `embed:""`
	models.DisplayFlags     `embed:""`
	models.AggregateFlags   `embed:""`
	models.FTSFlags         `embed:""`

	Args []string `help:"Database file(s) or files/directories to scan" required:"true" arg:""`

	Databases []string `kong:"-"`
	ScanPaths []string `kong:"-"`
}

func (*DiskUsageCmd) AfterApply

func (c *DiskUsageCmd) AfterApply() error

func (*DiskUsageCmd) Run

func (c *DiskUsageCmd) Run(ctx context.Context) error

type ExplodeCmd

type ExplodeCmd struct {
	TargetDir string `help:"Directory to create symlinks in" default:"." arg:"" optional:""`
}

func (*ExplodeCmd) Run

func (c *ExplodeCmd) Run(ctx *kong.Context) error

type ExtractionWorkersParams added in v0.0.38

type ExtractionWorkersParams struct {
	Jobs    <-chan string
	Results chan<- *metadata.MediaMetadata
	State   *processState
	Wg      *sync.WaitGroup
}

ExtractionWorkersParams contains the channels and synchronization primitives for extraction workers

type FilesInfoCmd

type FilesInfoCmd struct {
	models.CoreFlags        `embed:""`
	models.FilterFlags      `embed:""`
	models.TimeFilterFlags  `embed:""`
	models.MediaFilterFlags `embed:""`
	models.DisplayFlags     `embed:""`

	Args []string `help:"Database file(s) or files/directories to scan" required:"true" arg:""`

	Databases []string `kong:"-"`
	ScanPaths []string `kong:"-"`
}

func (*FilesInfoCmd) AfterApply

func (c *FilesInfoCmd) AfterApply() error

func (*FilesInfoCmd) Run

func (c *FilesInfoCmd) Run(ctx context.Context) error

type HistoryAddCmd

type HistoryAddCmd struct {
	models.CoreFlags `embed:""`

	Done bool     `help:"Mark as done"`
	Args []string `help:"Database file followed by paths to mark as played" required:"true" name:"args" arg:""`

	Paths    []string `kong:"-"`
	Database string   `kong:"-"`
}

func (*HistoryAddCmd) AfterApply

func (c *HistoryAddCmd) AfterApply() error

func (*HistoryAddCmd) Run

func (c *HistoryAddCmd) Run(ctx context.Context) error

type HistoryCmd

type HistoryCmd struct {
	models.CoreFlags        `embed:""`
	models.PathFilterFlags  `embed:""`
	models.FilterFlags      `embed:""`
	models.MediaFilterFlags `embed:""`
	models.TimeFilterFlags  `embed:""`
	models.DeletedFlags     `embed:""`
	models.SortFlags        `embed:""`
	models.DisplayFlags     `embed:""`
	models.PostActionFlags  `embed:""`

	Databases []string `help:"SQLite database files" required:"true" arg:"" type:"existingfile"`
}

func (*HistoryCmd) Run

func (c *HistoryCmd) Run(ctx context.Context) error

type KiwixInstance

type KiwixInstance struct {
	Process  *exec.Cmd
	Port     int
	ZimPath  string
	LastUsed time.Time
}

type KiwixManager

type KiwixManager struct {
	Instances map[string]*KiwixInstance // zimPath -> instance
	Mutex     sync.Mutex
	UsedPorts map[int]bool
}

func (*KiwixManager) EnsureKiwixServing added in v0.0.38

func (m *KiwixManager) EnsureKiwixServing(ctx context.Context, zimPath string) (int, error)

func (*KiwixManager) FindAvailablePort added in v0.0.38

func (m *KiwixManager) FindAvailablePort(ctx context.Context) int

type ListenCmd

type ListenCmd struct {
	models.CoreFlags        `embed:""`
	models.QueryFlags       `embed:""`
	models.PathFilterFlags  `embed:""`
	models.FilterFlags      `embed:""`
	models.MediaFilterFlags `embed:""`
	models.TimeFilterFlags  `embed:""`
	models.DeletedFlags     `embed:""`
	models.SortFlags        `embed:""`
	models.DisplayFlags     `embed:""`
	models.FTSFlags         `embed:""`
	models.PlaybackFlags    `embed:""`
	models.MpvActionFlags   `embed:""`
	models.PostActionFlags  `embed:""`

	Databases []string `help:"SQLite database files" required:"true" arg:"" type:"existingfile"`
}

func (*ListenCmd) Run

func (c *ListenCmd) Run(ctx context.Context) error

type LsEntry

type LsEntry struct {
	Name      string `json:"name"`
	Path      string `json:"path"`
	IsDir     bool   `json:"is_dir"`
	MediaType string `json:"media_type,omitempty"`
	Local     bool   `json:"local"`
}

LsEntry represents a directory listing entry

type MediaCheckCmd

type MediaCheckCmd struct {
	models.CoreFlags        `embed:""`
	models.PathFilterFlags  `embed:""`
	models.FilterFlags      `embed:""`
	models.MediaFilterFlags `embed:""`
	models.DeletedFlags     `embed:""`

	Databases []string `help:"SQLite database files" required:"true" arg:"" type:"existingfile"`

	ChunkSize         float64 `` /* 167-byte string literal not displayed */
	Gap               string  `` /* 166-byte string literal not displayed */
	DeleteCorrupt     string  `help:"Delete media that is more corrupt or equal to this threshold. Values greater than 1 are treated as number of seconds"`
	FullScanIfCorrupt string  `` /* 153-byte string literal not displayed */
	FullScan          bool    `help:"Decode the full media file"`
	AudioScan         bool    `help:"Count errors in audio track only"`
}

func (*MediaCheckCmd) Run

func (c *MediaCheckCmd) Run(ctx context.Context) error

type MergeDBsCmd

type MergeDBsCmd struct {
	models.CoreFlags   `embed:""`
	models.FilterFlags `embed:""`
	models.MergeFlags  `embed:""`

	TargetDB  string   `help:"Target SQLite database file"  required:"true" arg:""`
	SourceDBs []string `help:"Source SQLite database files" required:"true" arg:"" type:"existingfile"`
}

func (*MergeDBsCmd) Run

func (c *MergeDBsCmd) Run(ctx context.Context) error

type MergedCaption

type MergedCaption struct {
	Path  string
	Time  float64
	End   float64
	Text  string
	Title string
}

type MpvControlBase

type MpvControlBase struct {
	models.ControlFlags `embed:""`
}

type MpvWatchlaterCmd

type MpvWatchlaterCmd struct {
	models.CoreFlags        `embed:""`
	models.MediaFilterFlags `embed:""`
	models.PathFilterFlags  `embed:""`
	models.TimeFilterFlags  `embed:""`
	models.DeletedFlags     `embed:""`
	models.PlaybackFlags    `embed:""`

	Databases []string `help:"SQLite database files" required:"true" arg:"" type:"existingfile"`
}

func (*MpvWatchlaterCmd) Run

func (c *MpvWatchlaterCmd) Run(ctx context.Context) error

type NextCmd

type NextCmd struct {
	MpvControlBase
}

func (*NextCmd) Run

func (c *NextCmd) Run(ctx context.Context) error

type NowCmd

type NowCmd struct {
	MpvControlBase
}

func (*NowCmd) Run

func (c *NowCmd) Run(ctx context.Context) error

type OpdsEntry

type OpdsEntry struct {
	Title string `xml:"title"`
	Name  string `xml:"name"`
	Link  []struct {
		Rel  string `xml:"rel,attr"`
		Href string `xml:"href,attr"`
		Type string `xml:"type,attr"`
	} `xml:"link"`
}

type OpdsFeed

type OpdsFeed struct {
	XMLName xml.Name    `xml:"feed"`
	Entries []OpdsEntry `xml:"entry"`
}

type OpenCmd

type OpenCmd struct {
	models.CoreFlags        `embed:""`
	models.PathFilterFlags  `embed:""`
	models.FilterFlags      `embed:""`
	models.MediaFilterFlags `embed:""`
	models.SortFlags        `embed:""`
	models.PostActionFlags  `embed:""`

	Databases []string `help:"SQLite database files" required:"true" arg:"" type:"existingfile"`
}

func (*OpenCmd) Run

func (c *OpenCmd) Run(ctx context.Context) error

type OptimizeCmd

type OptimizeCmd struct {
	models.CoreFlags `embed:""`

	Databases []string `help:"SQLite database files" required:"true" arg:"" type:"existingfile"`
}

func (*OptimizeCmd) BulkMarkOptimizedExtensions added in v0.0.35

func (c *OptimizeCmd) BulkMarkOptimizedExtensions(ctx context.Context, sqlDB *sql.DB, _ *db.Queries) error

func (*OptimizeCmd) Run

func (c *OptimizeCmd) Run(ctx context.Context) error

type PauseCmd

type PauseCmd struct {
	MpvControlBase
}

func (*PauseCmd) Run

func (c *PauseCmd) Run(ctx context.Context) error

type PlaybackCommandParams added in v0.0.38

type PlaybackCommandParams struct {
	MpvCmd   string
	MpvArgs  []any
	CastCmd  string
	CastArgs []string
}

PlaybackCommandParams contains the command and arguments for mpv and chromecast playback

type PlaylistsCmd

type PlaylistsCmd struct {
	models.CoreFlags    `embed:""`
	models.DisplayFlags `embed:""`

	Databases []string `help:"SQLite database files" required:"true" arg:"" type:"existingfile"`
}

func (*PlaylistsCmd) Run

func (c *PlaylistsCmd) Run(ctx context.Context) error

type PrintCmd

type PrintCmd struct {
	models.CoreFlags        `embed:""`
	models.QueryFlags       `embed:""`
	models.PathFilterFlags  `embed:""`
	models.FilterFlags      `embed:""`
	models.MediaFilterFlags `embed:""`
	models.TimeFilterFlags  `embed:""`
	models.DeletedFlags     `embed:""`
	models.SortFlags        `embed:""`
	models.DisplayFlags     `embed:""`
	models.AggregateFlags   `embed:""`
	models.TextFlags        `embed:""`
	models.FTSFlags         `embed:""`

	Args []string `help:"Database file(s) or files/directories to scan" required:"true" arg:""`

	Databases []string `kong:"-"`
	ScanPaths []string `kong:"-"`
}

func (*PrintCmd) AfterApply

func (c *PrintCmd) AfterApply() error

func (*PrintCmd) Run

func (c *PrintCmd) Run(ctx context.Context) error

type QueryStats added in v0.0.34

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

QueryStats tracks slow query statistics

type QueryStatsResponse added in v0.0.34

type QueryStatsResponse struct {
	Queries      []SlowQueryEntry `json:"queries"`
	TotalCount   int              `json:"total_count"`
	SlowestQuery *SlowQueryEntry  `json:"slowest_query,omitempty"`
	AvgDuration  float64          `json:"avg_duration_ms"`
	StartTime    int64            `json:"start_time"` // Unix timestamp to avoid JSON marshaling issues
}

QueryStatsResponse is the response for the /api/queries endpoint

type ReadmeCmd

type ReadmeCmd struct {
	models.CoreFlags        `embed:""`
	models.QueryFlags       `embed:""`
	models.PathFilterFlags  `embed:""`
	models.FilterFlags      `embed:""`
	models.MediaFilterFlags `embed:""`
	models.TimeFilterFlags  `embed:""`
	models.DeletedFlags     `embed:""`
	models.SortFlags        `embed:""`
	models.DisplayFlags     `embed:""`
	models.AggregateFlags   `embed:""`
	models.TextFlags        `embed:""`
	models.SimilarityFlags  `embed:""`
	models.DedupeFlags      `embed:""`
	models.FTSFlags         `embed:""`
	models.PlaybackFlags    `embed:""`
	models.MpvActionFlags   `embed:""`
	models.PostActionFlags  `embed:""`
	models.HashingFlags     `embed:""`
	models.MergeFlags       `embed:""`
	models.DatabaseFlags    `embed:""`
}

func (*ReadmeCmd) Run

func (c *ReadmeCmd) Run(ctx *kong.Context) error

type RegexSortCmd

type RegexSortCmd struct {
	models.CoreFlags `embed:""`
	models.SortFlags `embed:""`
	models.TextFlags `embed:""`

	InputPath  string `help:"Input file path (default stdin)"   default:"-" arg:"" optional:""`
	OutputPath string `help:"Output file path (default stdout)"`

	// For testing
	Reader io.Reader `kong:"-"`
	Writer io.Writer `kong:"-"`
}

func (*RegexSortCmd) Run

func (c *RegexSortCmd) Run(ctx context.Context) error

type RepairCmd

type RepairCmd struct {
	models.CoreFlags `embed:""`

	Database string `help:"Database file to repair" required:"true" arg:"" type:"existingfile"`
}

func (*RepairCmd) Run

func (c *RepairCmd) Run(ctx context.Context) error

type SampleHashCmd

type SampleHashCmd struct {
	models.CoreFlags    `embed:""`
	models.HashingFlags `embed:""`
	models.DisplayFlags `embed:""`

	Paths []string `help:"Files to hash" required:"true" arg:"" type:"existingfile"`
}

func (*SampleHashCmd) Run

func (c *SampleHashCmd) Run(ctx context.Context) error

type SearchCaptionsCmd

type SearchCaptionsCmd struct {
	models.CoreFlags        `embed:""`
	models.QueryFlags       `embed:""`
	models.FTSFlags         `embed:""`
	models.MediaFilterFlags `embed:""`
	models.PlaybackFlags    `embed:""`

	Database string   `help:"SQLite database file" required:"true" arg:"" type:"existingfile"`
	Search   []string `help:"Search terms"         required:"true" arg:""`

	Open    bool `help:"Open results in media player"`
	Overlap int  `help:"Overlap in seconds for merging captions" default:"8"`
}

func (*SearchCaptionsCmd) Run

func (c *SearchCaptionsCmd) Run(ctx context.Context) error

type SearchCmd

type SearchCmd struct {
	models.CoreFlags        `embed:""`
	models.QueryFlags       `embed:""`
	models.PathFilterFlags  `embed:""`
	models.FilterFlags      `embed:""`
	models.MediaFilterFlags `embed:""`
	models.TimeFilterFlags  `embed:""`
	models.DeletedFlags     `embed:""`
	models.SortFlags        `embed:""`
	models.DisplayFlags     `embed:""`
	models.FTSFlags         `embed:""`

	Databases []string `help:"SQLite database files" required:"true" arg:"" type:"existingfile"`
}

func (*SearchCmd) Run

func (c *SearchCmd) Run(ctx context.Context) error

type SearchDBCmd

type SearchDBCmd struct {
	models.CoreFlags        `embed:""`
	models.QueryFlags       `embed:""`
	models.PathFilterFlags  `embed:""`
	models.FilterFlags      `embed:""`
	models.MediaFilterFlags `embed:""`
	models.TimeFilterFlags  `embed:""`
	models.DeletedFlags     `embed:""`
	models.DisplayFlags     `embed:""`
	models.PostActionFlags  `embed:""`

	Database string   `help:"SQLite database file"                  required:"true" arg:"" type:"existingfile"`
	Table    string   `help:"Table name (fuzzy matching supported)" required:"true" arg:""`
	Search   []string `help:"Search terms"                          required:"true" arg:""`
}

func (*SearchDBCmd) Run

func (c *SearchDBCmd) Run(ctx context.Context) error

type SeekCmd

type SeekCmd struct {
	MpvControlBase

	Time string `help:"Time to seek to (e.g. 10, +10, -10, 00:01:30)" arg:""`
}

func (*SeekCmd) Run

func (c *SeekCmd) Run(ctx context.Context) error

type ServeCmd

type ServeCmd struct {
	models.CoreFlags        `embed:""`
	models.QueryFlags       `embed:""`
	models.PathFilterFlags  `embed:""`
	models.FilterFlags      `embed:""`
	models.MediaFilterFlags `embed:""`
	models.TimeFilterFlags  `embed:""`
	models.DeletedFlags     `embed:""`
	models.SortFlags        `embed:""`
	models.DisplayFlags     `embed:""`
	models.AggregateFlags   `embed:""`
	models.PlaybackFlags    `embed:""`
	models.PostActionFlags  `embed:""`
	models.FTSFlags         `embed:""`

	Databases            []string `` /* 129-byte string literal not displayed */
	Port                 int      `` /* 154-byte string literal not displayed */
	PublicDir            string   `help:"Override embedded web assets with local directory"`
	Dev                  bool     `help:"Enable development mode (auto-reload)"`
	ReadOnly             bool     `help:"Disable write operations (progress tracking, playlist modifications, deletions)"`
	NoBrowser            bool     `help:"Don't open browser on startup"`
	ApplicationStartTime int64    `` /* 163-byte string literal not displayed */
	APIToken             string   `` /* 163-byte string literal not displayed */
	// contains filtered or unexported fields
}

ServeCmd is the HTTP server command

func (*ServeCmd) Close added in v0.0.15

func (c *ServeCmd) Close() error

Close closes all cached database connections

func (*ServeCmd) GetGlobalFlags

func (c *ServeCmd) GetGlobalFlags() models.GlobalFlags

GetGlobalFlags returns all embedded flag structs

func (*ServeCmd) HandleCategories added in v0.0.38

func (c *ServeCmd) HandleCategories(w http.ResponseWriter, r *http.Request)

func (*ServeCmd) HandleCategorizeApply added in v0.0.38

func (c *ServeCmd) HandleCategorizeApply(w http.ResponseWriter, r *http.Request)

func (*ServeCmd) HandleCategorizeDeleteCategory added in v0.0.38

func (c *ServeCmd) HandleCategorizeDeleteCategory(w http.ResponseWriter, r *http.Request)

func (*ServeCmd) HandleCategorizeKeyword added in v0.0.38

func (c *ServeCmd) HandleCategorizeKeyword(w http.ResponseWriter, r *http.Request)

func (*ServeCmd) HandleCategorizeKeywords added in v0.0.38

func (c *ServeCmd) HandleCategorizeKeywords(w http.ResponseWriter, r *http.Request)

func (*ServeCmd) HandleCategorizeSuggest added in v0.0.38

func (c *ServeCmd) HandleCategorizeSuggest(w http.ResponseWriter, r *http.Request)

func (*ServeCmd) HandleDU added in v0.0.38

func (c *ServeCmd) HandleDU(w http.ResponseWriter, r *http.Request)

func (*ServeCmd) HandleDatabases added in v0.0.38

func (c *ServeCmd) HandleDatabases(w http.ResponseWriter, _ *http.Request)

HandleDatabases returns server configuration. GET /api/databases

func (*ServeCmd) HandleDelete added in v0.0.38

func (c *ServeCmd) HandleDelete(w http.ResponseWriter, r *http.Request)

HandleDelete marks a file as deleted or restores it in all databases. POST /api/delete Body: {"path": "...", "restore": bool}

func (*ServeCmd) HandleEmptyBin added in v0.0.38

func (c *ServeCmd) HandleEmptyBin(w http.ResponseWriter, r *http.Request)

func (*ServeCmd) HandleEpisodes added in v0.0.38

func (c *ServeCmd) HandleEpisodes(w http.ResponseWriter, r *http.Request)

func (*ServeCmd) HandleEpubConvert added in v0.0.38

func (c *ServeCmd) HandleEpubConvert(w http.ResponseWriter, r *http.Request)

HandleEpubConvert serves converted EPUB/text documents as HTML format URL format: /api/epub/{path} serves index.html with custom TOC header URL format: /api/epub/{path}/{asset} serves CSS/images from the HTML directory

func (*ServeCmd) HandleEvents added in v0.0.38

func (c *ServeCmd) HandleEvents(w http.ResponseWriter, r *http.Request)

func (*ServeCmd) HandleFilterBins added in v0.0.38

func (c *ServeCmd) HandleFilterBins(w http.ResponseWriter, r *http.Request)

HandleFilterBins handles the /api/filter-bins endpoint

func (*ServeCmd) HandleGenres added in v0.0.38

func (c *ServeCmd) HandleGenres(w http.ResponseWriter, r *http.Request)

HandleGenres returns genre statistics. GET /api/genres

func (*ServeCmd) HandleHLSPlaylist added in v0.0.38

func (c *ServeCmd) HandleHLSPlaylist(w http.ResponseWriter, r *http.Request)

func (*ServeCmd) HandleHLSSegment added in v0.0.38

func (c *ServeCmd) HandleHLSSegment(w http.ResponseWriter, r *http.Request)

func (*ServeCmd) HandleHealth added in v0.0.38

func (c *ServeCmd) HandleHealth(w http.ResponseWriter, _ *http.Request)

HandleHealth returns OK if the server is running

func (*ServeCmd) HandleLanguages added in v0.0.38

func (c *ServeCmd) HandleLanguages(w http.ResponseWriter, r *http.Request)

HandleLanguages returns language statistics. GET /api/languages

func (*ServeCmd) HandleLs added in v0.0.38

func (c *ServeCmd) HandleLs(w http.ResponseWriter, r *http.Request)

func (*ServeCmd) HandleMarkPlayed added in v0.0.38

func (c *ServeCmd) HandleMarkPlayed(w http.ResponseWriter, r *http.Request)

HandleMarkPlayed increments play count and resets progress for a media file. POST /api/mark-played Body: {"path": "..."}

func (*ServeCmd) HandleMarkUnplayed added in v0.0.38

func (c *ServeCmd) HandleMarkUnplayed(w http.ResponseWriter, r *http.Request)

HandleMarkUnplayed resets play count and progress for a media file. POST /api/mark-unplayed Body: {"path": "..."}

func (*ServeCmd) HandleMetadata added in v0.0.38

func (c *ServeCmd) HandleMetadata(w http.ResponseWriter, r *http.Request)

HandleMetadata returns detailed metadata for a specific media file. GET /api/metadata?db=...&path=...

func (*ServeCmd) HandleOPDS added in v0.0.38

func (c *ServeCmd) HandleOPDS(w http.ResponseWriter, r *http.Request)

func (*ServeCmd) HandlePlay added in v0.0.38

func (c *ServeCmd) HandlePlay(w http.ResponseWriter, r *http.Request)

HandlePlay triggers local playback of a media file via mpv. POST /api/play Body: {"path": "..."}

func (*ServeCmd) HandlePlaylistItems added in v0.0.38

func (c *ServeCmd) HandlePlaylistItems(w http.ResponseWriter, r *http.Request)

func (*ServeCmd) HandlePlaylistReorder added in v0.0.38

func (c *ServeCmd) HandlePlaylistReorder(w http.ResponseWriter, r *http.Request)

func (*ServeCmd) HandlePlaylists added in v0.0.38

func (c *ServeCmd) HandlePlaylists(w http.ResponseWriter, r *http.Request)

func (*ServeCmd) HandleProgress added in v0.0.38

func (c *ServeCmd) HandleProgress(w http.ResponseWriter, r *http.Request)

HandleProgress updates the playback progress for a media file. POST /api/progress Body: {"path": "...", "playhead": int64, "completed": bool}

func (*ServeCmd) HandleQueries added in v0.0.38

func (c *ServeCmd) HandleQueries(w http.ResponseWriter, r *http.Request)

HandleQueries handles the /api/queries endpoint for slow query dashboard

func (*ServeCmd) HandleQuery added in v0.0.38

func (c *ServeCmd) HandleQuery(w http.ResponseWriter, r *http.Request)

HandleQuery handles media searching and filtering. GET /api/query?search=...&category=...&rating=...&sort=...&limit=...&offset=...

func (*ServeCmd) HandleRSVP added in v0.0.38

func (c *ServeCmd) HandleRSVP(w http.ResponseWriter, r *http.Request)

func (*ServeCmd) HandleRandomClip added in v0.0.38

func (c *ServeCmd) HandleRandomClip(w http.ResponseWriter, r *http.Request)

func (*ServeCmd) HandleRate added in v0.0.38

func (c *ServeCmd) HandleRate(w http.ResponseWriter, r *http.Request)

HandleRate updates the rating for a media file. POST /api/rate Body: {"path": "...", "score": float64}

func (*ServeCmd) HandleRatings added in v0.0.38

func (c *ServeCmd) HandleRatings(w http.ResponseWriter, r *http.Request)

HandleRatings returns rating statistics. GET /api/ratings

func (*ServeCmd) HandleRaw added in v0.0.38

func (c *ServeCmd) HandleRaw(w http.ResponseWriter, r *http.Request)

func (*ServeCmd) HandleSubtitles added in v0.0.38

func (c *ServeCmd) HandleSubtitles(w http.ResponseWriter, r *http.Request)

func (*ServeCmd) HandleThumbnail added in v0.0.38

func (c *ServeCmd) HandleThumbnail(w http.ResponseWriter, r *http.Request)

func (*ServeCmd) HandleTranscode added in v0.0.38

func (c *ServeCmd) HandleTranscode(
	w http.ResponseWriter,
	r *http.Request,
	path string,
	m models.Media,
	strategy utils.TranscodeStrategy,
)

func (*ServeCmd) HandleTrash added in v0.0.38

func (c *ServeCmd) HandleTrash(w http.ResponseWriter, r *http.Request)

func (*ServeCmd) HandleZimProxy added in v0.0.38

func (c *ServeCmd) HandleZimProxy(w http.ResponseWriter, r *http.Request)

func (*ServeCmd) HandleZimView added in v0.0.38

func (c *ServeCmd) HandleZimView(w http.ResponseWriter, r *http.Request)

func (*ServeCmd) Mux

func (c *ServeCmd) Mux() http.Handler

Mux creates the HTTP request multiplexer with all routes

func (*ServeCmd) ParseFlags added in v0.0.38

func (c *ServeCmd) ParseFlags(r *http.Request) models.GlobalFlags

ParseFlags extracts query parameters into GlobalFlags

func (*ServeCmd) Run

func (c *ServeCmd) Run(ctx context.Context) error

Run starts the HTTP server

type SimilarFilesCmd

type SimilarFilesCmd struct {
	models.CoreFlags        `embed:""`
	models.PathFilterFlags  `embed:""`
	models.FilterFlags      `embed:""`
	models.MediaFilterFlags `embed:""`
	models.TimeFilterFlags  `embed:""`
	models.SortFlags        `embed:""`
	models.DisplayFlags     `embed:""`
	models.SimilarityFlags  `embed:""`

	Databases []string `help:"SQLite database files" required:"true" arg:"" type:"existingfile"`
}

func (*SimilarFilesCmd) Run

func (c *SimilarFilesCmd) Run(ctx context.Context) error

type SimilarFoldersCmd

type SimilarFoldersCmd struct {
	models.CoreFlags        `embed:""`
	models.PathFilterFlags  `embed:""`
	models.FilterFlags      `embed:""`
	models.MediaFilterFlags `embed:""`
	models.TimeFilterFlags  `embed:""`
	models.SortFlags        `embed:""`
	models.DisplayFlags     `embed:""`
	models.SimilarityFlags  `embed:""`

	Databases []string `help:"SQLite database files" required:"true" arg:"" type:"existingfile"`
}

func (*SimilarFoldersCmd) Run

func (c *SimilarFoldersCmd) Run(ctx context.Context) error

type SlowQueryEntry added in v0.0.34

type SlowQueryEntry struct {
	Query        string        `json:"query"`
	Args         []any         `json:"args,omitempty"`
	Duration     time.Duration `json:"duration_ms"`
	Timestamp    time.Time     `json:"timestamp"`
	DB           string        `json:"db"`
	RowsAffected int64         `json:"rows_affected,omitempty"`
}

SlowQueryEntry represents a single slow query record

func GetQueryStats added in v0.0.34

func GetQueryStats() []SlowQueryEntry

GetQueryStats returns current query statistics

type StatsCmd

type StatsCmd struct {
	models.CoreFlags        `embed:""`
	models.PathFilterFlags  `embed:""`
	models.FilterFlags      `embed:""`
	models.MediaFilterFlags `embed:""`
	models.TimeFilterFlags  `embed:""`
	models.DeletedFlags     `embed:""`
	models.DisplayFlags     `embed:""`

	Facet     string   `help:"One of: watched, deleted, created, modified" required:"true" arg:""`
	Databases []string `help:"SQLite database files"                       required:"true" arg:"" type:"existingfile"`
}

func (*StatsCmd) Run

func (c *StatsCmd) Run(ctx context.Context) error

type StopCmd

type StopCmd struct {
	MpvControlBase
}

func (*StopCmd) Run

func (c *StopCmd) Run(ctx context.Context) error

type UpdateCmd

type UpdateCmd struct{}

func (*UpdateCmd) Run

func (c *UpdateCmd) Run(ctx context.Context) error

type VersionCmd

type VersionCmd struct {
	Verbose int `help:"Show verbose output including dependencies" short:"v" env:"DISCO_VERBOSE" type:"counter"`
}

func (*VersionCmd) Run

func (c *VersionCmd) Run(ctx context.Context) error

type WatchCmd

type WatchCmd struct {
	models.CoreFlags        `embed:""`
	models.QueryFlags       `embed:""`
	models.PathFilterFlags  `embed:""`
	models.FilterFlags      `embed:""`
	models.MediaFilterFlags `embed:""`
	models.TimeFilterFlags  `embed:""`
	models.DeletedFlags     `embed:""`
	models.SortFlags        `embed:""`
	models.DisplayFlags     `embed:""`
	models.FTSFlags         `embed:""`
	models.PlaybackFlags    `embed:""`
	models.MpvActionFlags   `embed:""`
	models.PostActionFlags  `embed:""`

	Databases []string `help:"SQLite database files" required:"true" arg:"" type:"existingfile"`
}

func (*WatchCmd) Run

func (c *WatchCmd) Run(ctx context.Context) error

Jump to

Keyboard shortcuts

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