Documentation
¶
Index ¶
- Variables
- func FindExe() (string, error)
- func Maximums[S []E, E any, V constraints.Ordered](s S, f func(E) (V, error)) S
- func ParseDuration(s string) (time.Duration, error)
- func ParseLines(r io.Reader) iter.Seq2[Line, error]
- type Con
- func (c *Con) BackupTitle(ctx context.Context, driveIndex, titleIndex int, dstDir string) (iter.Seq2[Line, error], error)
- func (c *Con) ListDrives(ctx context.Context) (*LineIterator[[]*DriveScanLine], error)
- func (c *Con) RunCmd(ctx context.Context, args ...string) (iter.Seq2[Line, error], error)
- func (c *Con) RunDefaultCmd(ctx context.Context, args ...string) (iter.Seq2[Line, error], error)
- func (c *Con) ScanDrive(ctx context.Context, driveIndex int) (*LineIterator[*Disc], error)
- type Config
- type CurrentProgressLine
- type Disc
- type DiscInfoLine
- type DriveScanLine
- type Info
- func (info Info) GetAttr(id defs.Attr) (string, error)
- func (info Info) GetAttrDefault(id defs.Attr, defaultValue string) string
- func (info Info) GetAttrDuration(id defs.Attr) (time.Duration, error)
- func (info Info) GetAttrInt(id defs.Attr) (int, error)
- func (info Info) GetCode(id defs.Attr) (int, error)
- func (info Info) GetCodeDefault(id defs.Attr, defaultValue int) int
- type InfoLine
- type Line
- type LineIterator
- type LineKind
- type MessageLine
- type ProgressBarLine
- type Stream
- type StreamInfoLine
- type Title
- type TitleCountLine
- type TitleInfoLine
- type TotalProgressLine
Constants ¶
This section is empty.
Variables ¶
var ( // ErrUnhandledLine is returned when attempting to parse a makemkvcon output // line with an unhandled prefix. ErrUnhandledLine = fmt.Errorf("unhandled line") // ErrNotFound is returned when something is not found. ErrNotFound = fmt.Errorf("not found") )
Functions ¶
func FindExe ¶
FindExe attempts to return the path of the makemkvcon executable on Linux and Darwin operating systems.
func Maximums ¶
func Maximums[S []E, E any, V constraints.Ordered](s S, f func(E) (V, error)) S
Maximums returns all elements of the slice that maximize the given function, i.e., where f(e) = max(f(e0), f(e1), ..., f(eN)).
func ParseDuration ¶
ParseDuration parses a duration string with hours, minutes and seconds values separated by colons like "1:22:33".
func ParseLines ¶
ParseLines parses makemkvcon output lines from r. It returns a sequence of [Line, error] where either Line is a parsed line or err is non-nil. The sequence ends after all lines have been parsed and r returns EOF. Individual line parsing errors do not trigger an early return.
Types ¶
type Con ¶
type Con struct {
// contains filtered or unexported fields
}
Con is the interface for running makemkvcon commands.
func New ¶
New returns a new Con.
If cfg.ExePath is empty, it will attempt to locate the executable automatically.
func (*Con) BackupTitle ¶
func (c *Con) BackupTitle(ctx context.Context, driveIndex, titleIndex int, dstDir string) (iter.Seq2[Line, error], error)
BackupTitle creates a backup of title titleIndex of drive driveIndex in dstDir. The directory is created automatically if necessary.
func (*Con) ListDrives ¶
func (c *Con) ListDrives(ctx context.Context) (*LineIterator[[]*DriveScanLine], error)
ListDrives returns the list of drives detected by makemkvcon.
func (*Con) RunCmd ¶
RunCmd runs an arbitrary makemkvcon command with the given args. It terminates when the context is canceled or the command terminates.
func (*Con) RunDefaultCmd ¶
RunDefaultCmd calls RunCmd with default args in addition to the specified args. Default args include -r (machine-readable output), --minlength, and --profile.
type Config ¶
type Config struct {
// ExePath is the path to the makemkvcon executable. It must exist.
ExePath string
// ProfilePath is the path to a makemkv profile XML file. makemkvcon relies
// on it for the app_DefaultSelectionString setting, which determines what
// streams (video, audio, and subtitles) are selected by default. It must
// exist if non-empty.
ProfilePath string
// ReadCacheSizeMB is the value that is passed with the --cache argument to
// makemkvcon. It must be at least 1.
ReadCacheSizeMB int64 `validate:"min=1"`
// MinLengthSeconds is the value that is passed with the --minlength argument
// to makemkvcon. It must be at least 1.
//
// It filters out titles with video streams less than the given length, which
// is very useful for weeding out unimportant streams.
MinLengthSeconds int64 `validate:"min=1"`
}
Config is the makemkvcon configuration.
type CurrentProgressLine ¶
type CurrentProgressLine struct {
// contains filtered or unexported fields
}
CurrentProgressLine represents a makemkvcon "PRGC" output line, which describes the current sub-task.
See https://makemkv.com/developers/usage.txt.
func ParseCurrentProgressLine ¶
func ParseCurrentProgressLine(s string) (*CurrentProgressLine, error)
ParseCurrentProgressLine parses the string that follows "PRGC:" in the output of makemkvcon.
func (*CurrentProgressLine) Kind ¶
func (l *CurrentProgressLine) Kind() LineKind
type Disc ¶
Disc is a sequence of titles plus some metadata.
func (*Disc) GetTitle ¶
GetTitle returns the title with the given index, creating it (and previous titles) if necessary.
func (*Disc) TitleCount ¶
TitleCount returns the number of titles on the disc.
func (*Disc) TitlesWithAngle ¶
TitlesWithAngle returns all titles with the given angle.
func (*Disc) TitlesWithLongestDuration ¶
TitlesWithLongestDuration returns all titles that tie for maximum duration.
func (*Disc) TitlesWithMostChapters ¶
TitlesWithMostChapters returns all titles that tie for maximum number of chapters.
func (*Disc) TitlesWithMostStreams ¶
TitlesWithMostStreams returns all titles that tie for maximum number of streams.
type DiscInfoLine ¶
type DiscInfoLine struct {
*InfoLine
}
DiscInfoLine represents a makemkvcon "CINFO" output line, which provides information about a disc.
See https://makemkv.com/developers/usage.txt.
func ParseDiscInfoLine ¶
func ParseDiscInfoLine(s string) (*DiscInfoLine, error)
ParseDiscInfo parses the string that follows "CINFO:" in the output of makemkvcon.
func (*DiscInfoLine) Kind ¶
func (l *DiscInfoLine) Kind() LineKind
type DriveScanLine ¶
type DriveScanLine struct {
Index int
Visible int
Enabled int
Flags int
DriveName string
DiscTitle string
VolumeName string
}
DriveScanLine represents a makemkvcon "DRV" output line, which describes a disc drive.
See https://makemkv.com/developers/usage.txt.
func ParseDriveScanLine ¶
func ParseDriveScanLine(s string) (*DriveScanLine, error)
ParseDriveScanLine parses the string that follows "DRV:" in the output of makemkvcon.
func (*DriveScanLine) Kind ¶
func (l *DriveScanLine) Kind() LineKind
type Info ¶
type Info []*InfoLine
Info is a slice of related InfoLines.
func (Info) GetAttr ¶
GetAttr returns the Value of the InfoLine where ID matches id or ErrNotFound if such a line does not exist.
func (Info) GetAttrDefault ¶
GetAttrDefault returns the Value of the InfoLine where ID matches id or defaultValue if such a line does not exist.
func (Info) GetAttrDuration ¶
GetAttrDuration is like GetAttr, except it also attempts to convert the value to a time.Duration.
func (Info) GetAttrInt ¶
GetAttrInto is like GetAttr, except it also attempts to convert the Value to an integer.
type InfoLine ¶
type InfoLine struct {
// ID is an integer that identifies the attribute.
ID defs.Attr
// Code is an integer that corresponds to Value, if Value is an enumeration.
Code int
// Value is the value of the attribute identified by ID.
Value string
// contains filtered or unexported fields
}
InfoLine is the common representation of the "CINFO", "TINFO" and "SINFO" makemkvcon output lines, which describe an attribute of a disc, title, or stream.
type LineIterator ¶
type LineIterator[T any] struct { Seq iter.Seq2[Line, error] // contains filtered or unexported fields }
LineIterator is a generic type that represents the lines output by a makemkvcon command and the generic final result.
func (*LineIterator[T]) GetResult ¶
func (li *LineIterator[T]) GetResult() (T, error)
GetResult returns the final result of the command.
type MessageLine ¶
type MessageLine struct {
Code int
Flags int
NumParams int
Message string
Format string
Params []string
}
MessageLine represents a makemkvcon "MSG" output line, which is an informational logging line.
See https://makemkv.com/developers/usage.txt.
func ParseMessageLine ¶
func ParseMessageLine(s string) (*MessageLine, error)
ParseMessageLine parses the string that follows "MSG:" in the output of makemkvcon.
func (*MessageLine) Kind ¶
func (l *MessageLine) Kind() LineKind
type ProgressBarLine ¶
type ProgressBarLine struct {
// Current represents the progress of the current sub-task.
Current int
// Total represents the progress of the overall task.
Total int
// Max is a constant denominator used to calculate the progress percentage.
Max int
}
ProgressBarLine represents a "PRGV" output line, which describes the progress of a task and sub-task.
See https://makemkv.com/developers/usage.txt.
func ParseProgressBarLine ¶
func ParseProgressBarLine(s string) (*ProgressBarLine, error)
ParseProgressBarLine parses the string that follows "PRGV:" in the output of makemkvcon.
func (*ProgressBarLine) CurrentProgress ¶
func (l *ProgressBarLine) CurrentProgress() float64
CurrentProgress returns the progress of the current sub-task as a percentage.
func (*ProgressBarLine) Kind ¶
func (l *ProgressBarLine) Kind() LineKind
func (*ProgressBarLine) TotalProgress ¶
func (l *ProgressBarLine) TotalProgress() float64
TotalProgress returns the progress of the overall task as a percentage.
type StreamInfoLine ¶
StreamInfoLine represents an "SINFO" makemkvcon output line, which provides information about a stream.
See https://makemkv.com/developers/usage.txt.
func ParseStreamInfoLine ¶
func ParseStreamInfoLine(s string) (*StreamInfoLine, error)
ParseStreamInfoLine parses the string that follows "SINFO:" in the output of makemkvcon.
func (*StreamInfoLine) Kind ¶
func (l *StreamInfoLine) Kind() LineKind
type Title ¶
type Title struct {
// Index is the index given by makemkv. Title numbers appear to be
// deterministic if makemkv is run with the same --minlength argument.
Index int
Info
Streams []*Stream
}
Title is a collection of Streams plus some metadata. It is identified by an index number. A Disc is made up of multiple Titles.
Streams may be video, audio, or subtitles.
type TitleCountLine ¶
type TitleCountLine struct {
Count int
}
TitleCountLine represents a "TCOUNT" makemkvcon output line, which describes the number of titles found on a disc.
See https://makemkv.com/developers/usage.txt.
func ParseTitleCountLine ¶
func ParseTitleCountLine(s string) (*TitleCountLine, error)
ParseTitleCountLine parses the string that follows "TCOUNT:" in the output of makemkvcon.
func (*TitleCountLine) Kind ¶
func (l *TitleCountLine) Kind() LineKind
type TitleInfoLine ¶
TitleInfoLine represents a makemkvcon "TINFO" output line, which provides information about a title.
See https://makemkv.com/developers/usage.txt.
func ParseTitleInfoLine ¶
func ParseTitleInfoLine(s string) (*TitleInfoLine, error)
ParseTitleInfoLine parses the string that follows "TINFO:" in the output of makemkvcon.
func (*TitleInfoLine) Kind ¶
func (l *TitleInfoLine) Kind() LineKind
type TotalProgressLine ¶
type TotalProgressLine struct {
// contains filtered or unexported fields
}
TotalProgressLine represents a makemkvcon "PRGT" output line, which describes the overall task being performed.
See https://makemkv.com/developers/usage.txt.
func ParseTotalProgressLine ¶
func ParseTotalProgressLine(s string) (*TotalProgressLine, error)
ParseTotalProgressLine parses the string that follows "PRGT:" in the output of makemkvcon.
func (*TotalProgressLine) Kind ¶
func (l *TotalProgressLine) Kind() LineKind