filesystem

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2026 License: GPL-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CollectVideoFiles

func CollectVideoFiles(ctx context.Context, source string, preferLargest bool) (string, []string, error)

CollectVideoFiles returns a selected video and candidate list for a non-disc source. A file source is returned regardless of extension. A directory scan is non-recursive, includes recognized video extensions, excludes sample-like names except !sample, and sorts candidates by path. Selection uses the first candidate unless preferLargest is set.

func CopyFile

func CopyFile(src, dst string) error

CopyFile copies src to dst, creating or truncating dst without creating its parent directory. It applies the source mode when available; copy failures may leave a partial destination.

func DetectDiscType

func DetectDiscType(ctx context.Context, root string) (string, error)

DetectDiscType recursively scans root for disc folder markers and returns "BDMV", "DVD", "HDDVD", or "" when none is found. BDMV matching is case-insensitive; VIDEO_TS and HVDVD_TS matching is exact.

func FormatDuration

func FormatDuration(seconds float64) string

FormatDuration truncates fractional seconds and formats the result as HH:MM:SS; hours are not capped at 24.

func GatherQueuePaths

func GatherQueuePaths(ctx context.Context, root string) ([]string, error)

GatherQueuePaths returns sorted absolute host paths for first-level upload candidates. A file root is returned directly; directory children are kept only when they are video files or directories containing video or disc data.

func IsVideoFile

func IsVideoFile(name string) bool

IsVideoFile reports whether name has a recognized extension, ignoring case.

func LimitQueuePaths

func LimitQueuePaths(paths []string, limit int) []string

LimitQueuePaths returns a defensive copy capped at limit. A non-positive limit returns all paths.

func SourceSize

func SourceSize(ctx context.Context, sourcePath, discType string, fileList []string, videoPath string) (int64, error)

SourceSize returns content size in bytes. Disc sources walk the full tree and report traversal errors. Other sources prefer nonblank fileList entries, fall back to videoPath when none remain, and silently skip missing, inaccessible, or non-regular files.

func SupportedVideoExtensions

func SupportedVideoExtensions() []string

SupportedVideoExtensions returns a sorted copy of recognized lowercase extensions.

Types

type MoviePlaylistHeader

type MoviePlaylistHeader struct {
	TypeIndicator             string
	VersionNumber             string
	PlaylistStartAddress      uint32
	PlaylistMarkStartAddress  uint32
	ExtensionDataStartAddress uint32
}

MoviePlaylistHeader represents the MPLS file header.

type PlaylistData

type PlaylistData struct {
	Length      uint32
	NbPlayItems uint16
	NbSubPaths  uint16
	PlayItems   []PlaylistItem
}

PlaylistInfo represents a parsed playlist structure.

type PlaylistInfo

type PlaylistInfo struct {
	File     string
	Duration float64
	Items    []PlaylistItem
	Score    float64
	Edition  string
}

PlaylistInfo describes one MPLS candidate. File and item names are basenames, Duration is seconds, item sizes are bytes, and Score ranks main-feature likelihood. Edition is currently left empty by discovery.

func DiscoverPlaylists

func DiscoverPlaylists(ctx context.Context, bdmvRoot string) ([]PlaylistInfo, error)

DiscoverPlaylists discovers and scores all MPLS files in a BDMV folder. It returns candidates ordered by descending score.

type PlaylistItem

type PlaylistItem struct {
	File string
	Size int64
}

PlaylistItem identifies one referenced stream basename and its size in bytes.

func ParseMPLS

func ParseMPLS(mpslPath string) (float64, []PlaylistItem, error)

ParseMPLS returns an MPLS playlist's duration in seconds and referenced M2TS basenames with stream sizes in bytes.

type PlaylistItemInfo

type PlaylistItemInfo struct {
	ClipName string
	InTime   uint32
	OutTime  uint32
}

PlaylistItemInfo represents a single play item in a playlist with timing info.

type Validator

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

func NewValidator

func NewValidator() *Validator

func NewValidatorWithLogger

func NewValidatorWithLogger(logger api.Logger) *Validator

func (*Validator) ValidatePaths

func (v *Validator) ValidatePaths(ctx context.Context, paths []string) ([]string, error)

ValidatePaths validates paths in input order and returns their absolute host forms without deduplication. It stops at the first invalid path or cancellation.

Jump to

Keyboard shortcuts

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