From de45c0be60e453e69263f5b32ab2ce2661dc74ca Mon Sep 17 00:00:00 2001 From: kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com> Date: Mon, 15 Jul 2024 14:24:53 +0000 Subject: [feature] more filetype support! (#3107) * add more supported file types to our media processor that ffmpeg supports, update supported mime type lists * add code comments to the supported mime types slice * don't check for zero value string, just parse * remove some unneeded consts which make the code a bit harder to read * fix test expected instance media mime types, use compact ffprobe json, simple media processing by type * final tweaks to media processing code * don't use safe divide where we don't need to --- internal/util/ptr.go | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'internal/util/ptr.go') diff --git a/internal/util/ptr.go b/internal/util/ptr.go index 0ad207617..d7c30da85 100644 --- a/internal/util/ptr.go +++ b/internal/util/ptr.go @@ -34,6 +34,15 @@ func Ptr[T any](t T) *T { return &t } +// PtrIf returns ptr value only if 't' non-zero. +func PtrIf[T comparable](t T) *T { + var z T + if t == z { + return nil + } + return &t +} + // PtrValueOr returns either value of ptr, or default. func PtrValueOr[T any](t *T, _default T) T { if t != nil { -- cgit v1.2.3