implement mediainput command group

note, set-cursor not currently working, possible bug in goobs
This commit is contained in:
2026-01-08 20:38:36 +00:00
parent f84908f668
commit f6fbf3c81f
3 changed files with 146 additions and 0 deletions

28
util.go
View File

@@ -3,8 +3,10 @@
package main
import (
"fmt"
"os"
"strings"
"time"
)
func snakeCaseToTitleCase(snake string) string {
@@ -36,3 +38,29 @@ func trimPrefix(s, prefix string) string {
}
return s
}
func parseTimeStringToSeconds(timeStr string) (float64, error) {
parts := strings.Split(timeStr, ":")
var durationStr string
switch len(parts) {
case 1:
// Format: SS -> "SSs"
durationStr = parts[0] + "s"
case 2:
// Format: MM:SS -> "MMmSSs"
durationStr = parts[0] + "m" + parts[1] + "s"
case 3:
// Format: HH:MM:SS -> "HHhMMmSSs"
durationStr = parts[0] + "h" + parts[1] + "m" + parts[2] + "s"
default:
return 0, fmt.Errorf("invalid time format: %s", timeStr)
}
duration, err := time.ParseDuration(durationStr)
if err != nil {
return 0, fmt.Errorf("failed to parse duration: %w", err)
}
return duration.Seconds(), nil
}