organizer

package
v0.3.4-alpha Latest Latest
Warning

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

Go to latest
Published: May 2, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OperationModeOrganize              = types.OperationModeOrganize
	OperationModeInPlace               = types.OperationModeInPlace
	OperationModeInPlaceNoRenameFolder = types.OperationModeInPlaceNoRenameFolder
	OperationModeMetadataArtwork       = types.OperationModeMetadataArtwork
	OperationModePreview               = types.OperationModePreview
)

Variables

View Source
var ParseOperationMode = types.ParseOperationMode

Functions

This section is empty.

Types

type InPlaceNoRenameFolderStrategy

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

func NewInPlaceNoRenameFolderStrategy

func NewInPlaceNoRenameFolderStrategy(fs afero.Fs, cfg *config.OutputConfig, _ *matcher.Matcher, engine *template.Engine) *InPlaceNoRenameFolderStrategy

func (*InPlaceNoRenameFolderStrategy) Execute

func (*InPlaceNoRenameFolderStrategy) Plan

func (s *InPlaceNoRenameFolderStrategy) Plan(match matcher.MatchResult, movie *models.Movie, destDir string, forceUpdate bool) (*OrganizePlan, error)

type InPlaceStrategy

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

func NewInPlaceStrategy

func NewInPlaceStrategy(fs afero.Fs, cfg *config.OutputConfig, m *matcher.Matcher, engine *template.Engine) *InPlaceStrategy

func (*InPlaceStrategy) Execute

func (s *InPlaceStrategy) Execute(plan *OrganizePlan) (*OrganizeResult, error)

func (*InPlaceStrategy) Plan

func (s *InPlaceStrategy) Plan(match matcher.MatchResult, movie *models.Movie, destDir string, forceUpdate bool) (*OrganizePlan, error)

type LinkMode

type LinkMode string

LinkMode controls how files are materialized when copy mode is enabled.

const (
	LinkModeNone LinkMode = ""
	LinkModeHard LinkMode = "hard"
	LinkModeSoft LinkMode = "soft"
)

func ParseLinkMode

func ParseLinkMode(raw string) (LinkMode, error)

ParseLinkMode validates and normalizes user input.

func (LinkMode) IsValid

func (m LinkMode) IsValid() bool

IsValid returns true if the mode is supported.

type MetadataArtworkStrategy

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

func NewMetadataArtworkStrategy

func NewMetadataArtworkStrategy(fs afero.Fs, cfg *config.OutputConfig) *MetadataArtworkStrategy

func (*MetadataArtworkStrategy) Execute

func (*MetadataArtworkStrategy) Plan

func (s *MetadataArtworkStrategy) Plan(match matcher.MatchResult, movie *models.Movie, destDir string, forceUpdate bool) (*OrganizePlan, error)

type OperationMode

type OperationMode = types.OperationMode

type OperationStrategy

type OperationStrategy interface {
	Plan(match matcher.MatchResult, movie *models.Movie, destDir string, forceUpdate bool) (*OrganizePlan, error)
	Execute(plan *OrganizePlan) (*OrganizeResult, error)
}

type OrganizePlan

type OrganizePlan struct {
	Match             matcher.MatchResult
	Movie             *models.Movie
	SourcePath        string
	TargetDir         string
	TargetFile        string
	TargetPath        string
	WillMove          bool
	Conflicts         []string
	InPlace           bool
	OldDir            string
	IsDedicated       bool
	SkipInPlaceReason string
	FolderName        string
	SubfolderPath     string
	BaseFileName      string
	Strategy          StrategyType
	// contains filtered or unexported fields
}

type OrganizeResult

type OrganizeResult struct {
	OriginalPath           string
	NewPath                string
	FolderPath             string
	FileName               string
	Moved                  bool
	Error                  error
	Subtitles              []SubtitleResult
	InPlaceRenamed         bool   // Whether an in-place directory rename occurred
	OldDirectoryPath       string // Original directory path (for updating subsequent file paths)
	NewDirectoryPath       string // New directory path after in-place rename
	ShouldGenerateMetadata bool   // Whether NFO/media should be generated for this result
}

OrganizeResult represents the result of organizing a file

type OrganizeStrategy

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

func NewOrganizeStrategy

func NewOrganizeStrategy(fs afero.Fs, cfg *config.OutputConfig, engine *template.Engine) *OrganizeStrategy

func (*OrganizeStrategy) Execute

func (s *OrganizeStrategy) Execute(plan *OrganizePlan) (*OrganizeResult, error)

func (*OrganizeStrategy) Plan

func (s *OrganizeStrategy) Plan(match matcher.MatchResult, movie *models.Movie, destDir string, forceUpdate bool) (*OrganizePlan, error)

type Organizer

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

Organizer handles file organization (moving/renaming)

func NewOrganizer

func NewOrganizer(fs afero.Fs, cfg *config.OutputConfig, engine *template.Engine) *Organizer

NewOrganizer creates a new file organizer

func (*Organizer) Copy

func (o *Organizer) Copy(plan *OrganizePlan, dryRun bool) (*OrganizeResult, error)

Copy copies a file instead of moving it

func (*Organizer) CopyWithLinkMode

func (o *Organizer) CopyWithLinkMode(plan *OrganizePlan, dryRun bool, linkMode LinkMode) (*OrganizeResult, error)

CopyWithLinkMode materializes a file using direct copy, hard link, or soft link.

func (*Organizer) Execute

func (o *Organizer) Execute(plan *OrganizePlan, dryRun bool) (*OrganizeResult, error)

Execute executes an organization plan

func (*Organizer) Organize

func (o *Organizer) Organize(match matcher.MatchResult, movie *models.Movie, destDir string, dryRun bool, forceUpdate bool, copyOnly bool) (*OrganizeResult, error)

Organize plans and executes file organization in one step

func (*Organizer) OrganizeBatch

func (o *Organizer) OrganizeBatch(matches []matcher.MatchResult, movies map[string]*models.Movie, destDir string, dryRun bool, forceUpdate bool, copyOnly bool) ([]OrganizeResult, error)

OrganizeBatch organizes multiple files

func (*Organizer) OrganizeBatchWithLinkMode

func (o *Organizer) OrganizeBatchWithLinkMode(
	matches []matcher.MatchResult,
	movies map[string]*models.Movie,
	destDir string,
	dryRun bool,
	forceUpdate bool,
	copyOnly bool,
	linkMode LinkMode,
) ([]OrganizeResult, error)

OrganizeBatchWithLinkMode organizes multiple files with optional link behavior for copy operations.

func (*Organizer) OrganizeWithLinkMode

func (o *Organizer) OrganizeWithLinkMode(
	match matcher.MatchResult,
	movie *models.Movie,
	destDir string,
	dryRun bool,
	forceUpdate bool,
	copyOnly bool,
	linkMode LinkMode,
) (*OrganizeResult, error)

OrganizeWithLinkMode plans and executes file organization with optional link behavior for copy operations.

func (*Organizer) Plan

func (o *Organizer) Plan(match matcher.MatchResult, movie *models.Movie, destDir string, forceUpdate bool) (*OrganizePlan, error)

func (*Organizer) SetMatcher

func (o *Organizer) SetMatcher(m *matcher.Matcher)

SetMatcher sets the matcher instance for in-place rename detection

func (*Organizer) ValidatePlan

func (o *Organizer) ValidatePlan(plan *OrganizePlan) []string

ValidatePlan checks if a plan is valid and safe to execute

type StrategyType

type StrategyType int

OrganizePlan represents a planned file organization operation

const (
	StrategyTypeOrganize StrategyType = iota
	StrategyTypeInPlace
	StrategyTypeInPlaceNoRenameFolder
	StrategyTypeMetadataArtwork
)

type SubtitleHandler

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

SubtitleHandler manages subtitle file operations

func NewSubtitleHandler

func NewSubtitleHandler(fs afero.Fs, cfg *config.OutputConfig) *SubtitleHandler

NewSubtitleHandler creates a new subtitle handler

func (*SubtitleHandler) FindSubtitles

func (sh *SubtitleHandler) FindSubtitles(videoFile scanner.FileInfo) []SubtitleMatch

FindSubtitles searches for subtitle files associated with a video file

func (*SubtitleHandler) MoveSubtitles

func (sh *SubtitleHandler) MoveSubtitles(subtitles []SubtitleMatch, targetDir, videoFileName string, dryRun bool) error

MoveSubtitles moves subtitle files to the target directory with the video file

type SubtitleMatch

type SubtitleMatch struct {
	OriginalPath string
	NewPath      string
	Language     string // ISO 639 language code if detectable
	Extension    string
}

SubtitleMatch represents a matched subtitle file

type SubtitleResult

type SubtitleResult struct {
	OriginalPath string
	NewPath      string
	Moved        bool
	Skipped      bool
	Planned      bool
	Error        error
}

SubtitleResult represents the result of moving a subtitle file

Jump to

Keyboard shortcuts

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