Documentation
¶
Index ¶
- func CreateVirtualDir(node *treeview.Node[treeview.FileInfo], mm *MediaMeta) (int, []error)
- func DeleteMarkedNode(node *treeview.Node[treeview.FileInfo], mm *MediaMeta) error
- func EnsureDestinationDir(path string, mm *MediaMeta) error
- func FetchFilePathMetadata(ctx context.Context, prov provider.Provider, item MetadataItem) (*provider.Metadata, error)
- func FetchProviderMetadata(ctx context.Context, prov provider.Provider, item MetadataItem, ...) (*provider.Metadata, error)
- func FormatMetadataProgressMessage(item MetadataItem) string
- func HasMetadataValues(meta *provider.Metadata) bool
- func LinkRegular(node *treeview.Node[treeview.FileInfo], mm *MediaMeta) (bool, error)
- func LinkVirtualDir(node *treeview.Node[treeview.FileInfo], mm *MediaMeta, linkPath string) (int, []error)
- func MergeMetadata(item MetadataItem, base *provider.Metadata, extras ...*provider.Metadata) *provider.Metadata
- func PreserveExistingBracketTags(generatedBaseName string, sourceBaseName string, enabled bool) string
- func RenameRegular(node *treeview.Node[treeview.FileInfo], mm *MediaMeta) (bool, error)
- func ShouldReplaceItemNode(existing MetadataItem, candidate MetadataItem) bool
- func ShouldRunFilePathProvider(item MetadataItem) bool
- type MediaMeta
- type MediaType
- type MetadataEngine
- func (e *MetadataEngine) Errors() []error
- func (e *MetadataEngine) Metadata() map[string]*provider.Metadata
- func (e *MetadataEngine) ProviderFailures() []MetadataFailure
- func (e *MetadataEngine) RetryProvider(ctx context.Context, key string, providerType MetadataProviderType, ...) (*MetadataFailure, error)
- func (e *MetadataEngine) Start(ctx context.Context) <-chan MetadataEvent
- func (e *MetadataEngine) SummarySnapshot() MetadataSummary
- type MetadataEngineConfig
- type MetadataEvent
- type MetadataFailure
- type MetadataItem
- type MetadataProviderType
- type MetadataResult
- type MetadataSummary
- type RenameStatus
- type SimpleFileInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateVirtualDir ¶ added in v1.13.0
CreateVirtualDir materializes a virtual movie directory then renames its children beneath it.
Returns a count of successful operations (directory creation + child renames), and contextual errors
func DeleteMarkedNode ¶ added in v1.13.0
DeleteMarkedNode removes the file on disk for a node marked for deletion.
func EnsureDestinationDir ¶ added in v1.13.0
EnsureDestinationDir makes sure the destination directory exists for link mode operations.
func FetchFilePathMetadata ¶ added in v1.19.2
func FetchFilePathMetadata(ctx context.Context, prov provider.Provider, item MetadataItem) (*provider.Metadata, error)
FetchFilePathMetadata retrieves metadata from providers that need the source media file path in the request extras.
func FetchProviderMetadata ¶ added in v1.19.2
func FetchProviderMetadata(ctx context.Context, prov provider.Provider, item MetadataItem, cache provider.MetadataCache) (*provider.Metadata, error)
FetchProviderMetadata retrieves metadata from a registry provider with retry/backoff handling for rate limits.
func FormatMetadataProgressMessage ¶ added in v1.13.0
func FormatMetadataProgressMessage(item MetadataItem) string
FormatMetadataProgressMessage builds a human readable description for progress updates.
func HasMetadataValues ¶ added in v1.13.0
func LinkRegular ¶ added in v1.13.0
LinkRegular creates a hard link from the source node to the destination path. Returns true only when an actual filesystem link was created.
func LinkVirtualDir ¶ added in v1.13.0
func LinkVirtualDir(node *treeview.Node[treeview.FileInfo], mm *MediaMeta, linkPath string) (int, []error)
LinkVirtualDir creates a virtual movie directory in the destination and links its children into it. Returns a count of successful operations (directory creation + child links), and contextual errors
func MergeMetadata ¶ added in v1.13.0
func MergeMetadata(item MetadataItem, base *provider.Metadata, extras ...*provider.Metadata) *provider.Metadata
MergeMetadata combines base metadata with additional provider results.
func PreserveExistingBracketTags ¶ added in v1.16.0
func RenameRegular ¶ added in v1.13.0
RenameRegular renames a node; returns true only when an actual filesystem rename occurred.
func ShouldReplaceItemNode ¶ added in v1.13.0
func ShouldReplaceItemNode(existing MetadataItem, candidate MetadataItem) bool
ShouldReplaceItemNode determines if the new candidate should replace the existing node reference.
func ShouldRunFilePathProvider ¶ added in v1.19.2
func ShouldRunFilePathProvider(item MetadataItem) bool
ShouldRunFilePathProvider determines whether a file-path provider should run for the item.
Types ¶
type MediaMeta ¶
type MediaMeta struct {
Type MediaType
NewName string
DestinationPath string // Full destination path when linking
RenameStatus RenameStatus
RenameError string
IsVirtual bool
NeedsDirectory bool
MarkedForDeletion bool
}
MediaMeta holds per-node rename intent and results.
Fields:
- Type: Media classification used for rule selection and statistics.
- NewName: Proposed final name (filename or directory name). Empty implies no change or unknown format.
- RenameStatus / RenameError: Outcome of the rename attempt. Error message is only populated when status == RenameStatusError.
- IsVirtual: True when the node does not (yet) exist on disk; used for synthesized movie directories wrapping loose video files.
- NeedsDirectory: Signals that a directory must be created before children are renamed beneath it (typically paired with IsVirtual).
- MarkedForDeletion: True when the file should be deleted during rename operation.
The zero value is meaningful: it encodes an untyped, unprocessed node with no rename proposal.
func EnsureMeta ¶
EnsureMeta returns the existing *MediaMeta for n, creating and attaching a new instance if needed. The returned pointer is always non-nil.
type MediaType ¶
type MediaType int
MediaType enumerates the semantic classification of a node within the media library hierarchy.
type MetadataEngine ¶ added in v1.13.0
type MetadataEngine struct {
// contains filtered or unexported fields
}
MetadataEngine orchestrates metadata fetching across multiple providers while exposing progress snapshots for UI consumption.
func NewMetadataEngine ¶ added in v1.13.0
func NewMetadataEngine(cfg MetadataEngineConfig) *MetadataEngine
NewMetadataEngine constructs an engine with sane defaults applied.
func (*MetadataEngine) Errors ¶ added in v1.13.0
func (e *MetadataEngine) Errors() []error
Errors returns a copy of the accumulated errors.
func (*MetadataEngine) Metadata ¶ added in v1.13.0
func (e *MetadataEngine) Metadata() map[string]*provider.Metadata
Metadata returns the aggregated metadata map. The map is safe to read once the engine has completed.
func (*MetadataEngine) ProviderFailures ¶ added in v1.14.0
func (e *MetadataEngine) ProviderFailures() []MetadataFailure
ProviderFailures returns a snapshot of provider errors that require manual intervention before progressing. The returned slice is a copy safe for modification by the caller.
func (*MetadataEngine) RetryProvider ¶ added in v1.14.0
func (e *MetadataEngine) RetryProvider(ctx context.Context, key string, providerType MetadataProviderType, nameOverride string) (*MetadataFailure, error)
RetryProvider re-executes a provider lookup using an optional manual search term. It returns nil when the failure has been resolved. If the provider still fails, the updated failure (including attempt count and error) is returned for display. A non-nil error indicates an unexpected engine issue.
func (*MetadataEngine) Start ¶ added in v1.13.0
func (e *MetadataEngine) Start(ctx context.Context) <-chan MetadataEvent
Start begins metadata fetching and returns a stream of progress events.
func (*MetadataEngine) SummarySnapshot ¶ added in v1.13.0
func (e *MetadataEngine) SummarySnapshot() MetadataSummary
SummarySnapshot returns the latest progress summary.
type MetadataEngineConfig ¶ added in v1.13.0
type MetadataEngineConfig struct {
Tree *treeview.Tree[treeview.FileInfo]
LocalProvider *local.Provider
WorkerCount int
Providers []provider.RuntimeConfig
}
MetadataEngineConfig configures provider access for the metadata engine.
type MetadataEvent ¶ added in v1.13.0
type MetadataEvent struct {
Summary MetadataSummary
Err error
}
MetadataEvent represents an update emitted by the engine.
type MetadataFailure ¶ added in v1.14.0
type MetadataFailure struct {
Item MetadataItem
Provider MetadataProviderType
Query string
Err error
Attempts int
}
MetadataFailure captures a provider-specific failure for a metadata item so callers (e.g., the TUI) can offer manual search overrides before proceeding.
type MetadataItem ¶ added in v1.13.0
type MetadataItem struct {
Name string
Year string
Season int
Episode int
IsMovie bool
Key string
Phase int
MediaType provider.MediaType
Node *treeview.Node[treeview.FileInfo]
}
MetadataItem represents an item that needs metadata.
func CollectMetadataItems ¶ added in v1.13.0
func CollectMetadataItems(tree *treeview.Tree[treeview.FileInfo], localProv *local.Provider) []MetadataItem
CollectMetadataItems walks the tree collecting unique metadata requests.
type MetadataProviderType ¶ added in v1.14.0
type MetadataProviderType string
MetadataProviderType identifies a metadata provider that can contribute results to the aggregation pipeline.
type MetadataResult ¶ added in v1.13.0
type MetadataResult struct {
Item MetadataItem
Meta *provider.Metadata
Errs []error
ProviderErrs map[MetadataProviderType]error
}
MetadataResult represents the result of fetching metadata for an item.
type MetadataSummary ¶ added in v1.13.0
type MetadataSummary struct {
TotalItems int
ProcessedItems int
ActiveWorkers int
WorkerLimit int
PhaseIndex int
PhaseName string
ActiveProviders []string
ErrorCount int
LastItem string
Done bool
Canceled bool
}
MetadataSummary captures the state of the metadata pipeline at a point in time.
type RenameStatus ¶
type RenameStatus int
RenameStatus represents the lifecycle stage of a proposed rename operation. A node starts at RenameStatusNone; after execution it is marked success or error with an accompanying message when relevant.
const ( RenameStatusNone RenameStatus = iota // Rename not yet attempted, or no change needed RenameStatusSuccess // Rename succeeded RenameStatusError // Rename failed; see RenameError for detail )
type SimpleFileInfo ¶
type SimpleFileInfo struct {
// contains filtered or unexported fields
}
SimpleFileInfo implements os.FileInfo for synthetic (virtual) nodes inserted into the tree (e.g. wrapping a standalone movie file in a virtual directory before materialization on disk).
func NewSimpleFileInfo ¶
func NewSimpleFileInfo(name string, isDir bool) *SimpleFileInfo
func (*SimpleFileInfo) IsDir ¶
func (m *SimpleFileInfo) IsDir() bool
func (*SimpleFileInfo) ModTime ¶
func (m *SimpleFileInfo) ModTime() time.Time
func (*SimpleFileInfo) Mode ¶
func (m *SimpleFileInfo) Mode() os.FileMode
func (*SimpleFileInfo) Name ¶
func (m *SimpleFileInfo) Name() string
func (*SimpleFileInfo) Size ¶
func (m *SimpleFileInfo) Size() int64
func (*SimpleFileInfo) Sys ¶
func (m *SimpleFileInfo) Sys() any