mirror of
https://git.unlock-music.dev/um/cli.git
synced 2025-07-06 22:42:12 +08:00
feat(meta): write album art & metadata into destination file
This commit is contained in:
24
internal/utils/temp.go
Normal file
24
internal/utils/temp.go
Normal file
@ -0,0 +1,24 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
)
|
||||
|
||||
func WriteTempFile(rd io.Reader, ext string) (string, error) {
|
||||
audioFile, err := os.CreateTemp("", "*"+ext)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("ffmpeg create temp file: %w", err)
|
||||
}
|
||||
|
||||
if _, err := io.Copy(audioFile, rd); err != nil {
|
||||
return "", fmt.Errorf("ffmpeg write temp file: %w", err)
|
||||
}
|
||||
|
||||
if err := audioFile.Close(); err != nil {
|
||||
return "", fmt.Errorf("ffmpeg close temp file: %w", err)
|
||||
}
|
||||
|
||||
return audioFile.Name(), nil
|
||||
}
|
Reference in New Issue
Block a user