analyze

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: AGPL-3.0 Imports: 14 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 analyze slowly works through the libraries in the background, recording each file's full media info: resolution and HDR, codecs and bitrates, audio channels and languages, subtitles. It is built to go unnoticed: one file at a time at the lowest CPU and disk priority, with a pause between files and while anyone is watching something transcoded, so network shares and the server stay responsive. Progress lives in the database, so it picks up where it was after a restart, and a file is looked at again only when it changes.

Index

Constants

View Source
const (
	StateAnalyzing = "analyzing"
	StateWaiting   = "waiting"    // for playback to finish
	StateSlowDisk  = "slowDisk"   // files kept timing out; resting before trying again
	StateIntros    = "intros"     // looking for the intros of a season's episodes
	StateCredits   = "credits"    // looking for the end credits of a season's episodes or a movie
	StateThumbs    = "thumbnails" // making a video's seek bar pictures
	StateGapless   = "gapless"    // listening for albums whose songs run into each other
	StateIdle      = "idle"       // everything is analyzed
	StateOff       = "off"
)

State says what the analysis is doing right now.

Variables

This section is empty.

Functions

This section is empty.

Types

type Analyzer

type Analyzer struct {
	Store  *store.Store
	Prober probe.Prober // should be LowPriority
	Log    *slog.Logger
	// Busy reports whether anyone is watching something the server is
	// transcoding right now. Gentle analysis waits until nobody is.
	Busy func() bool
	// Intros, when set, looks for TV episodes' intros once every file is
	// analyzed, at the same pace and priority.
	Intros *intro.Detector
	// Credits, when set, looks for where episodes' and movies' end credits
	// start after that, at the same pace and priority.
	Credits *credits.Detector
	// Thumbs, when set, makes the seek bar's pictures of every video after
	// that, when the admin has them made for all videos (see thumbs.Mode).
	Thumbs *thumbs.Generator
	// Gapless, when set, listens for albums whose songs run into each
	// other (see internal/gapless), after the intros.
	Gapless *gapless.Detector
	// contains filtered or unexported fields
}

func (*Analyzer) CreditsOn added in v0.1.13

func (a *Analyzer) CreditsOn(ctx context.Context) (bool, error)

CreditsOn says whether to look for end credits, an admin setting, on by default.

func (*Analyzer) IntrosOn added in v0.1.10

func (a *Analyzer) IntrosOn(ctx context.Context) (bool, error)

IntrosOn says whether to look for intros, an admin setting, on by default.

func (*Analyzer) Mode

func (a *Analyzer) Mode(ctx context.Context) (Mode, error)

Mode returns the admin's setting, Gentle unless they changed it.

func (*Analyzer) Reanalyze

func (a *Analyzer) Reanalyze(ctx context.Context, id int64) error

Reanalyze has one file looked at again soon, whatever its state, its intro and end credits looked for again and its seek bar pictures made again.

func (*Analyzer) Run

func (a *Analyzer) Run(ctx context.Context)

Run analyzes files until ctx ends.

func (*Analyzer) SetCreditsOn added in v0.1.13

func (a *Analyzer) SetCreditsOn(ctx context.Context, on bool) error

func (*Analyzer) SetIntrosOn added in v0.1.10

func (a *Analyzer) SetIntrosOn(ctx context.Context, on bool) error

func (*Analyzer) SetMode

func (a *Analyzer) SetMode(ctx context.Context, m Mode) error

func (*Analyzer) Status

func (a *Analyzer) Status(ctx context.Context) (Status, error)

func (*Analyzer) Wake

func (a *Analyzer) Wake()

Wake has the analysis look for new or changed files now, after a scan or a setting change, instead of at its next regular pass.

type IntroStatus added in v0.1.10

type IntroStatus struct {
	On    bool `json:"on"`
	Total int  `json:"total"`
	Done  int  `json:"done"`
	Found int  `json:"found"`
}

IntroStatus counts video episodes: all of them, the ones looked at for an intro, and the ones an intro was found in.

type Mode

type Mode string

Mode is how hard the analysis works, an admin setting.

const (
	// Gentle analyzes a file every few seconds and waits while anyone is
	// watching something transcoded. The default.
	Gentle Mode = "gentle"
	// Normal analyzes files back to back, still at the lowest priority.
	Normal Mode = "normal"
	// Off pauses the analysis until it's turned back on.
	Off Mode = "off"
)

type Status

type Status struct {
	Mode  Mode   `json:"mode"`
	State string `json:"state"`
	// Total is how many files the libraries have; Done how many are analyzed
	// as they are now, Unreadable among them the ones ffprobe couldn't read.
	Total      int    `json:"total"`
	Done       int    `json:"done"`
	Unreadable int    `json:"unreadable"`
	Current    string `json:"current,omitempty"`
	// Intros is how far looking for TV episodes' intros is; absent when
	// this server doesn't.
	Intros *IntroStatus `json:"intros,omitempty"`
	// Credits is how far looking for episodes' and movies' end credits is;
	// absent when this server doesn't. It counts episodes and movies.
	Credits *IntroStatus `json:"credits,omitempty"`
	// Thumbnails is how far making the seek bar's pictures is; absent when
	// this server doesn't.
	Thumbnails *ThumbStatus `json:"thumbnails,omitempty"`
}

Status is the analysis' progress, for admins.

type ThumbStatus added in v0.1.11

type ThumbStatus struct {
	Mode  thumbs.Mode `json:"mode"`
	Total int         `json:"total"`
	Done  int         `json:"done"`
}

ThumbStatus counts videos: all of them, and the ones with seek bar pictures (or that couldn't be read for them).

Jump to

Keyboard shortcuts

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