bulkimport

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2026 License: GPL-3.0 Imports: 28 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

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidPath = errors.New(
		"source path invalid (not absolute, doesn't exist, or not a directory)",
	)
	ErrPathOutsideLibrary = errors.New(
		"source path is outside library_path (in_place mode requires inside, rename mode requires outside)",
	)
	ErrLibraryPathMissing = errors.New(
		"configured library path (library.movie_path / library.series_path) does not exist or is not a directory",
	)
	ErrScanRunning        = errors.New("another scan is already active")
	ErrScanNotFound       = errors.New("scan not found")
	ErrScanFileNotFound   = errors.New("scan file not found")
	ErrScanNotReviewable  = errors.New("scan is not in awaiting_review state")
	ErrScanNotCancellable = errors.New("scan is not in a cancellable state")
	ErrScanNotDeletable   = errors.New("scan must be cancelled before delete")
)

Functions

func BuildShowParams added in v1.3.0

func BuildShowParams(
	folder string,
	p library.ParseResult,
	c ShowClassification,
	fileCount uint16,
) db.CreateImportScanShowParams

BuildShowParams turns a classified folder into the row to persist for review.

Types

type Classification

type Classification struct {
	Kind            entimportscanfile.Classification
	Candidates      []schema.ScannedCandidate
	TMDBID          uint32
	ExistingMovieID uint32
}

Classification holds the matcher's decision for a single scanned file.

func Classify

func Classify(
	parsed library.ParseResult,
	hits []metadata.MovieResult,
	alreadyAdded map[uint32]uint32,
) Classification

Classify decides how a parsed filename + TMDB hits + existing-library lookup fall into one of the four buckets. Existing-row collision wins over confirmed or ambiguous because attaching to an existing row beats creating a duplicate.

type FilesParams

type FilesParams struct {
	ScanID         uint32
	Classification entimportscanfile.Classification // empty = all
	Query          string
	Page           uint16
	Limit          uint16
}

FilesParams is the input for Manager.Files.

type Manager

type Manager interface {
	StartScan(ctx context.Context, p StartScanParams) (*ent.ImportScan, error)
	Get(ctx context.Context, id uint32) (*ent.ImportScan, error)
	List(ctx context.Context, page, limit uint16) ([]*ent.ImportScan, uint32, error)
	Files(ctx context.Context, p FilesParams) ([]*ent.ImportScanFile, uint32, error)
	GetFile(ctx context.Context, scanID, fileID uint32) (*ent.ImportScanFile, error)
	UpdateFileDecision(
		ctx context.Context,
		scanID, fileID uint32,
		decision entimportscanfile.Decision,
		tmdbID *uint32,
	) (*ent.ImportScanFile, error)
	Cancel(ctx context.Context, id uint32) error
	Commit(ctx context.Context, id uint32) error
	Delete(ctx context.Context, id uint32) error
	AbortInflight(ctx context.Context) (uint32, error)
}

Manager is the consumer-facing interface for the bulk-import service.

type SeriesAdder

type SeriesAdder interface {
	Add(
		ctx context.Context,
		tvdbID uint32,
		qualityProfile string,
	) (*ent.TVShow, error)
}

SeriesAdder creates a TV show (with its seasons and episodes) from a TVDB id. Satisfied by *tvshow.Service; used to adopt shows on series-scan commit.

type Service

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

Service implements Manager.

func NewService

func NewService(
	store db.Store,
	meta metadata.Provider,
	tvmeta metadata.TVProvider,
	importSvc *library.ImportService,
	movieSvc *movie.Service,
	seriesAdder SeriesAdder,
	moviePath string,
	seriesPath string,
) *Service

NewService constructs the bulk-import service.

func (*Service) AbortInflight

func (s *Service) AbortInflight(ctx context.Context) (uint32, error)

AbortInflight is the boot-time helper. Called from wire.go before the HTTP server starts.

func (*Service) Cancel

func (s *Service) Cancel(ctx context.Context, id uint32) error

func (*Service) Commit

func (s *Service) Commit(ctx context.Context, id uint32) error

func (*Service) Delete

func (s *Service) Delete(ctx context.Context, id uint32) error

func (*Service) Files

func (s *Service) Files(
	ctx context.Context,
	p FilesParams,
) ([]*ent.ImportScanFile, uint32, error)

func (*Service) Get

func (s *Service) Get(ctx context.Context, id uint32) (*ent.ImportScan, error)

func (*Service) GetFile

func (s *Service) GetFile(
	ctx context.Context,
	scanID, fileID uint32,
) (*ent.ImportScanFile, error)

func (*Service) List

func (s *Service) List(
	ctx context.Context,
	page, limit uint16,
) ([]*ent.ImportScan, uint32, error)

func (*Service) StartScan

func (s *Service) StartScan(
	ctx context.Context,
	p StartScanParams,
) (*ent.ImportScan, error)

StartScan validates params, creates the ImportScan row, and kicks off the scan goroutine. The goroutine uses context.WithoutCancel because the originating HTTP request ends within milliseconds; cancellation flows through DB state.

func (*Service) UpdateFileDecision

func (s *Service) UpdateFileDecision(
	ctx context.Context,
	scanID, fileID uint32,
	decision entimportscanfile.Decision,
	tmdbID *uint32,
) (*ent.ImportScanFile, error)

type ShowClassification added in v1.3.0

type ShowClassification struct {
	Kind             entimportscanshow.Classification
	TVDBID           uint32
	ExistingTvshowID uint32
	Candidates       []schema.ScannedShowCandidate
}

ShowClassification is the series analogue of Classification.

func ClassifyShow added in v1.3.0

func ClassifyShow(
	title string, year uint16,
	hits []metadata.TVResult, trackedByTVDB map[uint32]uint32,
) ShowClassification

ClassifyShow ranks TVDB results for a parsed folder into one of the four buckets. trackedByTVDB maps tvdb_id → tracked tvshow id; a candidate already in that set wins over confirmed/ambiguous because linking to the existing show beats creating a duplicate (mirrors Classify for movies).

type StartScanParams

type StartScanParams struct {
	SourcePath string
	Kind       entimportscan.Kind       // movie | series — empty defaults to movie
	Mode       entimportscan.Mode       // in_place | rename
	ImportMode entimportscan.ImportMode // optional — empty means "use library.import_mode default" (only meaningful when Mode == rename)
}

StartScanParams is the input for Service.StartScan.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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