mediasort

package
v0.0.0-...-0d13a8a Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2021 License: MIT Imports: 18 Imported by: 16

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	//DefaultTVTemplate defines the default TV path format
	DefaultTVTemplate = `{{ .Name }} S{{ printf "%02d" .Season }}E{{ printf "%02d" .Episode }}` +
		`{{ if ne .ExtraEpisode -1 }}-{{ printf "%02d" .ExtraEpisode }}{{end}}.{{ .Ext }}`
	//DefaultMovieTemplate defines the default movie path format
	DefaultMovieTemplate = "{{ .Name }} ({{ .Year }}).{{ .Ext }}"
)

Functions

func FileSystemSort

func FileSystemSort(c Config) error

FileSystemSort performs a media sort against the file system using the provided configuration

Types

type Action

type Action string

Action used to sort files

const (
	// MoveAction sorts by moving
	MoveAction Action = "move"
	// LinkAction sorts by linking
	LinkAction Action = "link"
	// CopyAction sorts by copying
	CopyAction Action = "copy"
)

type Config

type Config struct {
	Targets           []string `opts:"mode=arg,min=1"`
	TVDir             string   `opts:"help=tv series base directory (defaults to current directory)"`
	MovieDir          string   `opts:"help=movie base directory (defaults to current directory)"`
	PathConfig        `mode:"embedded"`
	Extensions        string        `opts:"help=types of files that should be sorted"`
	Concurrency       int           `opts:"help=search concurrency [warning] setting this too high can cause rate-limiting errors"`
	FileLimit         int           `opts:"help=maximum number of files to search"`
	NumDirs           int           `opts:"help=number of directories to include in search (default 0 where -1 means all dirs)"`
	AccuracyThreshold int           `opts:"help=filename match accuracy threshold" default:"is 95, perfect match is 100"`
	MinFileSize       sizestr.Bytes `opts:"help=minimum file size"`
	Recursive         bool          `opts:"help=also search through subdirectories"`
	DryRun            bool          `opts:"help=perform sort but don't actually move any files"`
	SkipHidden        bool          `opts:"help=skip dot files"`
	SkipSubs          bool          `opts:"help=skip subtitles (srt files)"`
	Action            Action        `opts:"help=filesystem action used to sort files (copy|link|move)"`
	HardLink          bool          `opts:"help=use hardlinks instead of symlinks (forces --action link)"`
	Overwrite         bool          `opts:"help=overwrites duplicates"`
	OverwriteIfLarger bool          `opts:"help=overwrites duplicates if the new file is larger"`
	Watch             bool          `opts:"help=watch the specified directories for changes and re-sort on change"`
	WatchDelay        time.Duration `opts:"help=delay before next sort after a change"`
	Verbose           bool          `opts:"help=verbose logs"`
}

Config is a sorter configuration

type PathConfig

type PathConfig struct {
	TVTemplate    string `help:"tv series path template"`
	MovieTemplate string `help:"movie path template"`
}

PathConfig customises the path templates

type Result

type Result struct {
	Query                         string
	Name, Path                    string
	Ext                           string
	MType                         string
	Season, Episode, ExtraEpisode int
	EpisodeDate                   string //weekly series
	Year                          string
	Accuracy                      int
}

Result holds both the results from parsing path, and the from performing the search

func Sort

func Sort(path string) (*Result, error)

Sort the given path, creates a search query, performing the search and returning a Result

func SortDepthThreshold

func SortDepthThreshold(path string, depth, threshold int) (*Result, error)

SortDepthThreshold sorts the given path, includes <depth> parent directories, creates a search query, performing the search with the given threshold and returning a Result

func SortThreshold

func SortThreshold(path string, threshold int) (*Result, error)

SortThreshold sorts the given path, creates a search query, performing the search with the given threshold and returning a Result

func (*Result) PrettyPath

func (result *Result) PrettyPath(config PathConfig) (string, error)

PrettyPath converts the provided "messy" path into a "pretty" cleanly formatted path using the media result

Jump to

Keyboard shortcuts

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