taggart

Simple golang tagging filesystem webapp
Log | Files | Refs

commit d04a1707b08e4716c06f7fcadcb6eea7b4f1efc4
parent ad3ecee61035b81ad673c67a598d37f82d87475e
Author: breadcat <breadcat@users.noreply.github.com>
Date:   Wed,  1 Oct 2025 22:27:50 +0100

Oneline sanitize filenames and ffmpeg

Diffstat:
Mmain.go | 24+++---------------------
1 file changed, 3 insertions(+), 21 deletions(-)

diff --git a/main.go b/main.go @@ -1264,11 +1264,7 @@ func sanitizeFilename(filename string) string { if filename == "" { return "file" } - - filename = strings.ReplaceAll(filename, "/", "_") - filename = strings.ReplaceAll(filename, "\\", "_") - filename = strings.ReplaceAll(filename, "..", "_") - + filename = strings.ReplaceAll(strings.ReplaceAll(strings.ReplaceAll(filename, "/", "_"), "\\", "_"), "..", "_") if filename == "" { return "file" } @@ -1412,26 +1408,12 @@ func generateThumbnail(videoPath, uploadDir, filename string) error { thumbPath := filepath.Join(thumbDir, filename+".jpg") - // Use ffmpeg to grab a frame in the first 5s, resize width to 400px - cmd := exec.Command("ffmpeg", "-y", - "-ss", "00:00:05", // seek to 5s - "-i", videoPath, - "-vframes", "1", - "-vf", "scale=400:-1", - thumbPath, - ) - + cmd := exec.Command("ffmpeg", "-y", "-ss", "00:00:05", "-i", videoPath, "-vframes", "1", "-vf", "scale=400:-1", thumbPath) cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr if err := cmd.Run(); err != nil { - // fallback: try frame 0 if grabbing at 5s fails - cmd := exec.Command("ffmpeg", "-y", - "-i", videoPath, - "-vframes", "1", - "-vf", "scale=400:-1", - thumbPath, - ) + cmd := exec.Command("ffmpeg", "-y", "-i", videoPath, "-vframes", "1", "-vf", "scale=400:-1", thumbPath) cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr if err2 := cmd.Run(); err2 != nil {