organizer

package
v0.2.3-alpha Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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 OrganizePlan

type OrganizePlan struct {
	Match             matcher.MatchResult
	Movie             *models.Movie
	SourcePath        string
	TargetDir         string
	TargetFile        string
	TargetPath        string
	WillMove          bool
	Conflicts         []string
	InPlace           bool   // Whether renaming folder in-place
	OldDir            string // Original directory path (for in-place renames)
	IsDedicated       bool   // Whether source folder is dedicated to this ID
	SkipInPlaceReason string // Reason why in-place was not used
}

OrganizePlan represents a planned file organization operation

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
}

OrganizeResult represents the result of organizing a file

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) *Organizer

NewOrganizer creates a new file organizer

func (*Organizer) CleanEmptyDirectories

func (o *Organizer) CleanEmptyDirectories(path string, baseDir string) error

CleanEmptyDirectories removes empty directories up to the base path

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)

Plan creates an organization plan without executing it

func (*Organizer) Revert

func (o *Organizer) Revert(result *OrganizeResult) error

Revert reverts an organization operation (moves file back)

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