Documentation
¶
Index ¶
- Constants
- Variables
- func AdjustDuration(duration int, start *int, end *int) int
- func AllowDictsLikeSQL(data []map[string]any, allowlist []map[string]any) []map[string]any
- func AltName(path string) string
- func AutoUpdate()
- func BlockDictsLikeSQL(data []map[string]any, blocklist []map[string]any) []map[string]any
- func BoolToInt64(b bool) int64
- func CalculatePercentiles(values []int64) []int64
- func CalculateSegments(total float64, chunk float64, gap float64) []float64
- func CalculateSegmentsInt(total int64, chunk int64, gap float64) []int64
- func CastCommand(castDevice string, args ...string) error
- func Chunks[T any](slice []T, chunkSize int) [][]T
- func CleanPath(path string, opts CleanPathOptions) string
- func CleanString(s string) string
- func CmdDetach(name string, args ...string) error
- func CmdInteractive(name string, args ...string) error
- func ColDuration(data []map[string]any, key string) []map[string]any
- func ColFilesize(data []map[string]any, key string) []map[string]any
- func ColNaturalDate(data []map[string]any, key string) []map[string]any
- func Combine(vals ...any) string
- func CommandExists(cmd string) bool
- func CommonPath(paths []string) string
- func CommonPathFull(paths []string) string
- func CompareBlockStrings(pattern, value string) bool
- func Concat[T any](slices ...[]T) []T
- func Confirm(message string) bool
- func Conform[T any](v any) []T
- func ConstructSearchBindings(include, exclude, columns []string, exact bool) (string, map[string]any)
- func ConvertEpubToOEB(inputPath string) (string, error)
- func CorpusStats(corpus [][]string) map[string]int
- func CountWordsFast(b []byte) int
- func DetectMimeType(path string) string
- func DictFilterBool(d map[string]any) map[string]any
- func DirExists(path string) bool
- func DivideSequence[T Number](slice []T) float64
- func Divisors(n int) []int
- func DurationShort(seconds int) string
- func EscapeXML(s string) string
- func EstimateDurationFromSize(size int64, isVideo bool) float64
- func EstimateDurationFromSizeWithFormat(size int64, ext string) float64
- func EstimateReadingDuration(wordCount int) int64
- func EstimateWordCountFromSize(path string, size int64) int
- func ExpandStdin(paths []string) []string
- func ExtractSubtitleInfo(subPath string) (displayName, languageCode, codec string)
- func ExtractText(path string) (string, error)
- func ExtractWords(s string) []string
- func FileExists(path string) bool
- func FilterDeleted(paths []string) []string
- func FilterPath(path string, flags models.PathFilterFlags) bool
- func FindMainContentFile(oebDir string) string
- func Flatten(v any) []any
- func FlattenWrapperFolder(outputDir string) error
- func Float64Value(f *float64) float64
- func FloatFromPercent(s string) (float64, error)
- func FolderSize(path string) int64
- func FormatDuration(seconds int) string
- func FormatDurationShort(seconds int) string
- func FormatPlaybackDuration(duration, segmentStart, segmentEnd int64) string
- func FormatSize(bytes int64) string
- func FormatTime(timestamp int64) string
- func FromTimestampSeconds(s string) float64
- func FtsQuote(query []string) []string
- func FullHashFile(path string) (string, error)
- func FzfSelect(items []string, multi bool) ([]string, error)
- func GenerateHLSPlaylist(path string, duration float64, segmentDuration int) string
- func GenerateRSVPAss(text string, wpm int) (string, float64)
- func GenerateTTS(text string, outputPath string, wpm int) error
- func GetCattNowPlayingFile() string
- func GetClearLineSequence() string
- func GetCommandPath(name string) string
- func GetConfigDir() string
- func GetContentTypeFromExt(ext string) string
- func GetDefaultBrowser() string
- func GetDurationForTimeout(duration float64, size int64, ext string) float64
- func GetEstimatedBitrate(ext string) int
- func GetExternalSubtitles(path string) []string
- func GetFloat64(v any) float64
- func GetHLSSegmentArgs(path string, startTime float64, segmentDuration int, ...) []string
- func GetHTMLFiles(dir string) []string
- func GetImageBrightness(data []byte) (float64, error)
- func GetInt(v any) int
- func GetInt64(v any) int64
- func GetLanguageCode(name string) string
- func GetLanguageName(code string) string
- func GetMpvListenSocket() string
- func GetMpvSocketPath(provided string) string
- func GetMpvWatchLaterDir() string
- func GetMpvWatchSocket() string
- func GetPathDisplayWidth() int
- func GetPlayhead(flags models.GlobalFlags, path string, startTime time.Time, ...) int
- func GetString(v any) string
- func GetTempDir() string
- func GetTerminalWidth() int
- func GlobMatchAll(path string, patterns []string) bool
- func GlobMatchAny(path string, patterns []string) bool
- func HasUnreliableDuration(ext string) bool
- func HumanToBits(s string) (int64, error)
- func HumanToBytes(s string) (int64, error)
- func HumanToSeconds(s string) (int64, error)
- func Int64Value(i *int64) int64
- func IsDigit(s string) bool
- func IsEmptyFolder(path string) bool
- func IsFileOpen(path string) bool
- func IsGenericTitle(title string) bool
- func IsImageTooDark(data []byte, threshold float64) bool
- func IsLanguageCode(s string) bool
- func IsSQLite(path string) bool
- func IsTZAware(t time.Time) bool
- func IsTimecodeLike(s string) bool
- func LastChars(s string) string
- func LineSorter(flags models.GlobalFlags, corpusStats map[string]int, originalLines []string, ...) []string
- func LineSplitter(regexs []*regexp.Regexp, line string) []string
- func LinearInterpolation(x float64, dataPoints [][2]float64) float64
- func ListDictFilterBool(data []map[string]any) []map[string]any
- func LoadString(s string) any
- func MatchesAny(path string, patterns []string) bool
- func Max[T Number](a, b T) T
- func MaybeUpdate() bool
- func Min[T Number](a, b T) T
- func MostSimilarSchema(keys []string, existingTables map[string]map[string]string) string
- func MpvArgsToMap(argStrings []string) map[string]string
- func MpvGetProperty(socketPath string, name string) (any, error)
- func MpvLoadFile(socketPath string, path string, mode string) error
- func MpvPause(socketPath string, pause bool) error
- func MpvSeek(socketPath string, value float64, mode string) error
- func MpvSetProperty(socketPath string, name string, value any) error
- func MpvWatchLaterValue(path, key string) (string, error)
- func NaturalLess(s1, s2 string) bool
- func OrderedSet[T comparable](slice []T) []T
- func ParseBitrate(s string) int64
- func ParseDate(dateStr string) int64
- func ParseDateOrRelative(dateStr string) int64
- func ParseDurationString(s string) time.Duration
- func ParsePercentOrBytes(s string) float64
- func ParsePercentileRange(s string) (min, max float64, ok bool)
- func ParseSize(s string) int64
- func PartialStartswith(s string, list []string) (string, error)
- func PathToMpvWatchLaterMD5(path string) string
- func PathToSentence(path string) string
- func PathToTokenized(path string) string
- func PathTupleFromURL(rawURL string) (string, string)
- func Percent(value, total float64) float64
- func PercentageDifference(v1, v2 float64) float64
- func Percentile[T Number](slice []T, p float64) float64
- func PrintJSON(data any) error
- func PrintOverwrite(text string)
- func Prompt(message string) string
- func QuickWordCount(path string, size int64) (int, error)
- func RandomFilename(path string) string
- func RandomFloat() float64
- func RandomInt(min, max int) int
- func RandomString(n int) string
- func ReadLines(r io.Reader) []string
- func RelativeDatetime(timestamp int64) string
- func Relativize(path string) string
- func RemoveConsecutive(s, char string) string
- func RemoveConsecutiveWhitespace(s string) string
- func RemoveConsecutives(s string, chars []string) string
- func RemoveExcessiveLinebreaks(s string) string
- func RemovePrefixes(s string, prefixes []string) string
- func RemoveSuffixes(s string, suffixes []string) string
- func RemoveTextInsideBrackets(s string) string
- func Rename(flags models.GlobalFlags, src, dst string) error
- func RenameMoveFile(flags models.GlobalFlags, src, dst string) error
- func RenameNoReplace(src, dst string) error
- func ResolveAbsolutePath(s string) string
- func Rmtree(flags models.GlobalFlags, path string) error
- func SafeFloat(s string) *float64
- func SafeIndex[T comparable](slice []T, val T) int
- func SafeInt(s string) *int
- func SafeJSONLoads(s string) any
- func SafeJoin(base string, userPath string) string
- func SafeLen[T any](slice []T) int
- func SafeMean[T Number](slice []T) float64
- func SafeMedian[T Number](slice []T) float64
- func SafePop[T any](slice []T) (T, []T)
- func SafeSum[T Number](slice []T) T
- func SafeUnpack[T comparable](vals ...T) T
- func SampleHashFile(path string, threads int, gap float64, chunkSize int64) (string, error)
- func SanitizeFilename(name string) string
- func SecondsToHHMMSS(seconds int64) string
- func Shorten(text string, maxWidth int) string
- func ShortenMiddle(text string, maxWidth int) string
- func ShouldOverrideDuration(reportedDuration float64, size int64, ext string) (float64, bool)
- func Similarity[T comparable](a, b []T) float64
- func SizeTimeout(timeoutSize string, totalSize int64) bool
- func SpecificDate(dates ...string) *time.Time
- func SplitAndTrim(s, sep string) []string
- func SqlHumanTime(s string) string
- func StringValue(s *string) string
- func StripEnclosingQuotes(s string) string
- func StripMountSyntax(path string) string
- func SuperParser(dateStr string) *time.Time
- func TextProcessor(flags models.GlobalFlags, lines []string) []string
- func Title(s string) string
- func ToDecade(year int) string
- func ToNullFloat64(f float64) sql.NullFloat64
- func ToNullInt64(i int64) sql.NullInt64
- func ToNullString(s string) sql.NullString
- func Trash(flags models.GlobalFlags, path string) error
- func TrimPathSegments(path string, desiredLength int) string
- func TruncateMiddle(s string, max int) string
- func TubeDate(v map[string]any) *int64
- func UnParagraph(s string) string
- func Unique[T comparable](slice []T) []T
- func Unlink(flags models.GlobalFlags, path string) error
- func UtcFromLocalTimestamp(n int64) time.Time
- func ValueCounts[T comparable](slice []T) []int
- func WordSorter(flags models.GlobalFlags, corpusStats map[string]int, lineWords []string) []string
- type CleanPathOptions
- type CmdResult
- type FileStats
- type HybridSearchQuery
- type MpvCommand
- type MpvResponse
- type Number
- type PlainHandler
- type Range
- type Slice
- type TerminalWidth
- type TranscodeStrategy
Constants ¶
const ( DefaultTableLimit = 350 DefaultPlayQueue = 120 DefaultSubtitleMix = 0.35 DefaultFileRowsReadLimit = 500000 DefaultMultiplePlayback = -1 DefaultOpenLimit = 7 )
const ( DefaultAudioBitrate = 256000 // 256 kbps DefaultVideoBitrate = 1500000 // 1500 kbps )
Default bitrates for duration estimation (bits per second)
Variables ¶
var ( ApplicationStart = time.Now().Unix() IsWindows = runtime.GOOS == "windows" IsLinux = runtime.GOOS == "linux" IsMac = runtime.GOOS == "darwin" TERMINAL_SIZE = struct{ columns, rows int }{80, 24} )
var ( VideoExtensionMap = make(map[string]bool) AudioExtensionMap = make(map[string]bool) ImageExtensionMap = make(map[string]bool) TextExtensionMap = make(map[string]bool) ComicExtensionMap = make(map[string]bool) ArchiveExtensionMap = make(map[string]bool) MediaExtensionMap = make(map[string]bool) )
var ( Stdin io.Reader = os.Stdin Stdout io.Writer = os.Stdout Stderr io.Writer = os.Stderr )
var ( // Version is the git version that produced this binary. Version string // When is the datestamp that produced this binary. When string // BuildSettings contains additional build information. BuildSettings []debug.BuildSetting // Deps contains dependency information. Deps []*debug.Module )
var ArchiveExtensions = []string{
"7z", "arj", "arc", "adf", "br", "bz2", "gz", "iso", "lha", "lzh", "lzx", "pak", "rar", "sit", "tar", "tar.bz2", "tar.gz", "tar.xz", "tar.zst", "tbz2", "tgz", "txz", "tzst", "xz", "zoo", "zip", "zst", "zstd", "cbz", "cbr",
}
var AudioExtensions = []string{
"mka", "opus", "oga", "ogg", "mp3", "mpga", "m2a", "m4a", "m4r", "caf", "m4b", "flac", "wav", "pcm", "aif", "aiff", "wma", "aac", "aa3", "ac3", "ape", "dsf", "dff",
}
var ComicExtensions = []string{
"cbz", "cbr",
}
var ImageExtensions = []string{}/* 146 elements not displayed */
var SQLiteExtensions = []string{".sqlite", ".sqlite3", ".db", ".db3", ".s3db", ".sl3"}
var SubtitleExtensions = []string{
"srt", "vtt", "mks", "ass", "ssa", "lrc", "idx", "sub",
}
var TextExtensions = []string{
"txt", "epub", "mobi", "pdf", "azw", "azw3", "fb2", "djvu", "zim",
}
var UnreliableDurationFormats = map[string]int{
".vob": 5000000,
".ifo": 5000000,
".vro": 5000000,
".m2t": 15000000,
".m2ts": 15000000,
".mts": 15000000,
".mod": 10000000,
".tod": 12000000,
".divx": 4000000,
".xvid": 4000000,
".rm": 2000000,
".rmvb": 3000000,
".wmv": 3000000,
".asf": 3000000,
".avchd": 20000000,
".bdmv": 30000000,
".mpls": 30000000,
".iso": 8000000,
}
UnreliableDurationFormats are formats known to have unreliable duration metadata (DVD, Blu-ray, camcorder formats, and older codecs) The int value is the estimated bitrate in bits per second for each format
var VideoExtensions = []string{}/* 281 elements not displayed */
Functions ¶
func AllowDictsLikeSQL ¶
AllowDictsLikeSQL filters data by keeping only items that match at least one pattern in the allowlist
func AutoUpdate ¶
func AutoUpdate()
AutoUpdate will periodically check for an update and install it.
func BlockDictsLikeSQL ¶
BlockDictsLikeSQL filters data by removing items that match any pattern in the blocklist
func BoolToInt64 ¶
func CalculatePercentiles ¶
func CalculateSegments ¶
func CalculateSegmentsInt ¶
func CastCommand ¶
CastCommand builds and executes a catt command with optional device specification
func CleanPath ¶
func CleanPath(path string, opts CleanPathOptions) string
func CleanString ¶
func CmdInteractive ¶
CmdInteractive runs a command connected to the current process's terminal
func CommandExists ¶ added in v0.0.34
CommandExists checks if a command is available in PATH or common installation paths Results are cached to avoid repeated syscalls
func CommonPath ¶
CommonPath returns the longest common path prefix Always returns forward slashes for cross-platform consistency
func CommonPathFull ¶
CommonPathFull returns a common path prefix. Previously it included common words in the suffix, but this was confusing for UI.
func CompareBlockStrings ¶
CompareBlockStrings implements SQL-like % wildcard matching
func ConstructSearchBindings ¶
func ConstructSearchBindings(include, exclude, columns []string, exact bool) (string, map[string]any)
ConstructSearchBindings returns a SQL where clause and a map of named bindings for inclusion and exclusion
func ConvertEpubToOEB ¶
ConvertEpubToOEB converts EPUB/text documents to HTML format using calibre's ebook-convert. The converted files are stored in ~/.cache/disco with automatic cleanup of files older than 3 days. Returns the path to the converted HTML directory.
func CorpusStats ¶
CorpusStats returns word counts across all lines
func CountWordsFast ¶ added in v0.0.30
CountWordsFast estimates word count by counting spaces. This is much faster than strings.Fields() and sufficient for duration estimation.
func DetectMimeType ¶
DetectMimeType returns the mimetype of a file based on extension Used only for HTTP Content-Type headers in streaming
func DivideSequence ¶
func DurationShort ¶
func EstimateDurationFromSize ¶ added in v0.0.34
EstimateDurationFromSize estimates duration from file size and bitrate Returns duration in seconds
func EstimateDurationFromSizeWithFormat ¶ added in v0.0.34
EstimateDurationFromSizeWithFormat estimates duration from file size using format-specific bitrate Returns duration in seconds
func EstimateReadingDuration ¶ added in v0.0.30
EstimateReadingDuration calculates reading duration in seconds from word count. Uses average reading speed of 220 words per minute.
func EstimateWordCountFromSize ¶ added in v0.0.30
EstimateWordCountFromSize estimates word count from file size. Uses format-specific ratios to account for images, formatting, etc. Returns estimated word count.
func ExpandStdin ¶
func ExtractSubtitleInfo ¶
ExtractSubtitleInfo extracts language and codec information from a subtitle filename Returns (displayName, languageCode, codec) Examples:
- movie.en.srt -> "English (ssa)", "en", "ssa" (ass is displayed as ssa)
- movie_eng.ass -> "English (ssa)", "eng", "ssa"
- movie.srt -> "srt", "", "srt"
- movie.EN.srt -> "English (ssa)", "en", "ssa"
- movie - English.srt -> "English (srt)", "en", "srt" (full language names supported)
func ExtractText ¶
ExtractText extracts plain text from a given file path. Supports a wide range of text and document formats. Uses lightweight tools first (pdftotext, native zip), with calibre as fallback.
func ExtractWords ¶
func FileExists ¶
func FilterDeleted ¶
FilterDeleted returns only the paths that currently exist on the filesystem
func FilterPath ¶
func FilterPath(path string, flags models.PathFilterFlags) bool
FilterPath checks if a path matches PathFilterFlags
func FindMainContentFile ¶
FindMainContentFile finds the main HTML content file in a calibre output directory Skips cover/metadata pages and finds the actual book content
func FlattenWrapperFolder ¶
FlattenWrapperFolder removes a single subfolder if it's the only entry in outputDir
func Float64Value ¶ added in v0.0.30
func FloatFromPercent ¶
func FolderSize ¶
FolderSize calculates the total size of all files in a folder (recursively)
func FormatDuration ¶
func FormatDurationShort ¶
func FormatPlaybackDuration ¶
func FormatSize ¶
func FormatTime ¶
func FromTimestampSeconds ¶
func FullHashFile ¶
FullHashFile calculates a full sha256 hash of a file
func GenerateHLSPlaylist ¶
func GenerateRSVPAss ¶
GenerateRSVPAss generates an ASS subtitle file content for RSVP.
func GenerateTTS ¶
GenerateTTS generates a WAV file from text using espeak-ng.
func GetCattNowPlayingFile ¶
func GetCattNowPlayingFile() string
func GetClearLineSequence ¶ added in v0.0.34
func GetClearLineSequence() string
GetClearLineSequence returns the escape sequence to clear/overwrite a line. We use \x1b[K (Erase from cursor to end of line) which is standard for overwriting.
func GetCommandPath ¶ added in v0.0.34
GetCommandPath returns the absolute path to a command
func GetConfigDir ¶
func GetConfigDir() string
func GetContentTypeFromExt ¶ added in v0.0.34
GetContentTypeFromExt returns the content type based on file extension
func GetDefaultBrowser ¶
func GetDefaultBrowser() string
func GetDurationForTimeout ¶ added in v0.0.34
GetDurationForTimeout returns a duration value suitable for timeout calculations. If the provided duration is valid (> 0), it returns it as-is. If duration is <= 0, it estimates from file size:
- For unreliable formats (DVD, Blu-ray, etc.), uses format-specific bitrate
- For other formats, uses default video bitrate
Returns 0 if size is invalid (<= 0)
func GetEstimatedBitrate ¶ added in v0.0.34
GetEstimatedBitrate returns the estimated bitrate for a format Returns 0 if the format is not in the unreliable formats map
func GetExternalSubtitles ¶
GetExternalSubtitles finds external subtitle files associated with a media file Supports patterns: movie.srt, movie.en.srt, movie_eng.srt, movie.EN.srt, movie.eng.srt, etc.
func GetFloat64 ¶
func GetHLSSegmentArgs ¶
func GetHLSSegmentArgs(path string, startTime float64, segmentDuration int, strategy TranscodeStrategy) []string
func GetHTMLFiles ¶
GetHTMLFiles returns a list of HTML files in the directory sorted by filename
func GetImageBrightness ¶ added in v0.0.32
GetImageBrightness calculates the average brightness of an image. Returns a value between 0.0 (black) and 1.0 (white).
func GetLanguageCode ¶ added in v0.0.10
GetLanguageCode converts a full language name to its code
func GetLanguageName ¶ added in v0.0.10
GetLanguageName converts a language code to its full name
func GetMpvListenSocket ¶
func GetMpvListenSocket() string
func GetMpvSocketPath ¶
GetMpvSocketPath returns the socket path to use, either from provided value or default
func GetMpvWatchLaterDir ¶
func GetMpvWatchLaterDir() string
func GetMpvWatchSocket ¶
func GetMpvWatchSocket() string
func GetPathDisplayWidth ¶ added in v0.0.34
func GetPathDisplayWidth() int
GetPathDisplayWidth returns the recommended width for displaying paths Takes into account terminal width and leaves room for other columns
func GetPlayhead ¶
func GetPlayhead(flags models.GlobalFlags, path string, startTime time.Time, existingPlayhead int, mediaDuration int) int
GetPlayhead calculates the playhead position based on session duration, existing playhead and mpv watch_later
func GetTempDir ¶
func GetTempDir() string
func GetTerminalWidth ¶ added in v0.0.34
func GetTerminalWidth() int
GetTerminalWidth returns the current terminal width
func GlobMatchAll ¶
func GlobMatchAny ¶
func HasUnreliableDuration ¶ added in v0.0.34
HasUnreliableDuration checks if a file extension is known to have unreliable duration metadata
func HumanToBits ¶
func HumanToBytes ¶
func HumanToSeconds ¶
func Int64Value ¶
func IsEmptyFolder ¶
IsEmptyFolder checks if a folder contains no files (recursively)
func IsFileOpen ¶
IsFileOpen checks if a file is currently open by any process
func IsGenericTitle ¶
func IsImageTooDark ¶ added in v0.0.32
IsImageTooDark returns true if the image brightness is below the threshold.
func IsLanguageCode ¶ added in v0.0.10
IsLanguageCode checks if a string looks like a language code
func IsTZAware ¶
IsTZAware checks if a time is not in the Local or UTC location (as a proxy for "aware") In Go, time.Time is always aware of its Location.
func IsTimecodeLike ¶
func LineSorter ¶
func LineSorter(flags models.GlobalFlags, corpusStats map[string]int, originalLines []string, corpus [][]string) []string
LineSorter sorts original lines based on their processed words
func LineSplitter ¶
LineSplitter splits a line into words using multiple regex patterns
func LinearInterpolation ¶
func LoadString ¶
func MatchesAny ¶
func MaybeUpdate ¶
func MaybeUpdate() bool
MaybeUpdate will check for an update and install it immediately. Returns true if an update was successfully installed and the process should restart.
func MostSimilarSchema ¶
MostSimilarSchema finds the table in existingTables that has the most columns in common with keys
func MpvArgsToMap ¶
MpvArgsToMap parses mpv command line arguments into a map
func MpvGetProperty ¶
MpvGetProperty gets a property from mpv
func MpvLoadFile ¶
MpvLoadFile loads a file into mpv
func MpvSetProperty ¶
MpvSetProperty sets a property in mpv
func MpvWatchLaterValue ¶
MpvWatchLaterValue reads a value for a given key from an mpv watch_later file
func NaturalLess ¶
func OrderedSet ¶
func OrderedSet[T comparable](slice []T) []T
func ParseBitrate ¶ added in v0.0.34
ParseBitrate parses a human-readable bitrate string to int64 bits per second
func ParseDateOrRelative ¶
UtcFromLocalTimestamp converts a local Unix timestamp to a UTC time.Time ParseDateOrRelative parses a date string into a Unix timestamp. It supports absolute dates (YYYY-MM-DD) and relative strings (e.g., "3 days").
func ParseDurationString ¶ added in v0.0.34
ParseDurationString parses duration strings like "10s", "20m", "1h". Defaults to minutes if no unit is specified.
func ParsePercentOrBytes ¶ added in v0.0.34
ParsePercentOrBytes parses a string like "5%" or "100MB" into a float64 ratio or bytes
func ParsePercentileRange ¶
func PathToMpvWatchLaterMD5 ¶
PathToMpvWatchLaterMD5 returns the MD5 hash of the absolute path, which mpv uses for filenames
func PathToSentence ¶
func PathToTokenized ¶ added in v0.0.30
func PathTupleFromURL ¶
PathTupleFromURL returns (parentDir, filename) from a URL
func PercentageDifference ¶
func Percentile ¶
func PrintOverwrite ¶
func PrintOverwrite(text string)
PrintOverwrite overwrites the current line in the terminal with the given text
func QuickWordCount ¶ added in v0.0.30
QuickWordCount extracts text and counts words for duration estimation. Optimized for speed over accuracy - suitable for ingest-time processing. Returns word count and error. For files with very low word counts (<300), falls back to size-based estimation to avoid false positives from sparse or image-heavy files.
func RandomFilename ¶
RandomFilename appends a random string to the filename before the extension
func RandomFloat ¶
func RandomFloat() float64
func RandomString ¶
RandomString returns a random hexadecimal string of the given length
func RelativeDatetime ¶
func Relativize ¶
Relativize removes leading slashes and drive letters
func RemoveConsecutive ¶
func RemoveConsecutives ¶
func RemovePrefixes ¶
func RemoveSuffixes ¶
func Rename ¶
func Rename(flags models.GlobalFlags, src, dst string) error
Rename renames a file, respecting simulation mode
func RenameMoveFile ¶
func RenameMoveFile(flags models.GlobalFlags, src, dst string) error
RenameMoveFile moves a file from src to dst, creating parent directories if needed
func RenameNoReplace ¶
RenameNoReplace renames a file only if the destination does not exist
func ResolveAbsolutePath ¶
ResolveAbsolutePath expands user home and returns absolute path if it exists
func Rmtree ¶
func Rmtree(flags models.GlobalFlags, path string) error
Rmtree deletes a directory tree, respecting simulation mode
func SafeIndex ¶
func SafeIndex[T comparable](slice []T, val T) int
func SafeJSONLoads ¶
func SafeJoin ¶
SafeJoin joins a base path with a user-provided path, preventing directory traversal
func SafeMedian ¶
func SafeUnpack ¶
func SafeUnpack[T comparable](vals ...T) T
func SampleHashFile ¶
SampleHashFile calculates a hash based on small file segments
func SanitizeFilename ¶
SanitizeFilename replaces special characters with underscores for calibre compatibility
func SecondsToHHMMSS ¶
func ShortenMiddle ¶
func ShouldOverrideDuration ¶ added in v0.0.34
ShouldOverrideDuration determines if reported duration should be overridden with an estimate based on file size. Returns true only when:
- File extension matches an unreliable format
- Reported duration is suspiciously low (< 2 minutes)
- Estimated duration is much higher (> 2 minutes)
func Similarity ¶
func Similarity[T comparable](a, b []T) float64
func SizeTimeout ¶
func SpecificDate ¶
SpecificDate finds the earliest most-specific past date from a list of strings
func SplitAndTrim ¶
func SqlHumanTime ¶
func StringValue ¶
func StripEnclosingQuotes ¶
func StripMountSyntax ¶
StripMountSyntax is a repeated relativize
func SuperParser ¶
SuperParser uses dateparse to attempt to parse a date string with various strategies
func TextProcessor ¶
func TextProcessor(flags models.GlobalFlags, lines []string) []string
TextProcessor orchestrates the splitting and sorting of text lines
func ToNullFloat64 ¶
func ToNullFloat64(f float64) sql.NullFloat64
func ToNullInt64 ¶
func ToNullString ¶
func ToNullString(s string) sql.NullString
func Trash ¶
func Trash(flags models.GlobalFlags, path string) error
Trash moves a file to the system trash if available, otherwise deletes it
func TrimPathSegments ¶
TrimPathSegments reduces the length of path segments to fit within desiredLength. It uses a fish-shell style where parent/grandparent segments are reduced to their first letter.
func TruncateMiddle ¶ added in v0.0.34
TruncateMiddle truncates a string in the middle with ellipsis
func UnParagraph ¶
func Unique ¶
func Unique[T comparable](slice []T) []T
func Unlink ¶
func Unlink(flags models.GlobalFlags, path string) error
Unlink deletes a file, respecting simulation mode
func UtcFromLocalTimestamp ¶
func ValueCounts ¶
func ValueCounts[T comparable](slice []T) []int
func WordSorter ¶
WordSorter sorts words within a line based on various criteria
Types ¶
type CleanPathOptions ¶
type CmdResult ¶
CmdResult wraps the output of a command execution
type FileStats ¶
func GetFileStats ¶
GetFileStats returns size and timestamps for a file
type HybridSearchQuery ¶ added in v0.0.30
type HybridSearchQuery struct {
// FTS terms: individual words searched via FTS5 (works with detail=none)
FTSTerms []string
// Phrases: exact phrases searched via LIKE (trigram-optimized)
Phrases []string
// Original query for reference
Original string
}
HybridSearchQuery holds the split query components for hybrid FTS+LIKE search
func ParseHybridSearchQuery ¶ added in v0.0.30
func ParseHybridSearchQuery(query string) *HybridSearchQuery
ParseHybridSearchQuery splits a search query into FTS terms and phrase patterns Phrases are quoted strings like "exact phrase" Terms are unquoted words searched via FTS
func (*HybridSearchQuery) BuildFTSQuery ¶ added in v0.0.30
func (h *HybridSearchQuery) BuildFTSQuery(joinOp string) string
BuildFTSQuery constructs the FTS MATCH query from terms For trigram + detail=none, we use first 3 chars of each word for filtering This is a loose filter - actual matching is done by LIKE for phrases
func (*HybridSearchQuery) BuildFTSQueryExact ¶ added in v0.0.30
func (h *HybridSearchQuery) BuildFTSQueryExact(joinOp string) string
BuildFTSQueryExact constructs an exact FTS MATCH query Uses full terms instead of trigrams for precise matching
func (*HybridSearchQuery) HasFTSTerms ¶ added in v0.0.30
func (h *HybridSearchQuery) HasFTSTerms() bool
HasFTSTerms returns true if the query contains FTS term searches
func (*HybridSearchQuery) HasPhrases ¶ added in v0.0.30
func (h *HybridSearchQuery) HasPhrases() bool
HasPhrases returns true if the query contains phrase searches
type MpvCommand ¶
type MpvCommand struct {
Command []any `json:"command"`
}
type MpvResponse ¶
type PlainHandler ¶
type Slice ¶
func ParseSlice ¶
type TerminalWidth ¶ added in v0.0.34
type TerminalWidth struct {
// contains filtered or unexported fields
}
TerminalWidth tracks the current terminal width and updates on resize
type TranscodeStrategy ¶
type TranscodeStrategy struct {
NeedsTranscode bool
VideoCopy bool
AudioCopy bool
TargetMime string
}
func GetTranscodeStrategy ¶
func GetTranscodeStrategy(m models.Media) TranscodeStrategy
Source Files
¶
- consts.go
- db.go
- files.go
- formatting.go
- fts_hybrid.go
- image.go
- io.go
- is_file_open_unix.go
- iterables.go
- logger.go
- mpv.go
- nums.go
- path_utils.go
- printing.go
- processes.go
- processes_unix.go
- rsvp.go
- selfupdate.go
- shell_utils.go
- strings.go
- terminal_common.go
- terminal_unix.go
- text_processor.go
- time.go
- transcode.go
- utils.go
- version.go