feat: enhance YouTube download functionality with chunked requests and audio conversion

This commit is contained in:
Fd
2026-07-17 17:24:44 +07:00
parent 43a559bd55
commit 24338beaaf
4 changed files with 133 additions and 19 deletions
+13
View File
@@ -1,11 +1,24 @@
package helper
import (
"bytes"
"os/exec"
"strings"
hc "neo/context"
)
func ConvertToMP3(data []byte) ([]byte, error) {
cmd := exec.Command("ffmpeg", "-i", "pipe:0", "-f", "mp3", "-ab", "128k", "pipe:1")
cmd.Stdin = bytes.NewReader(data)
var out bytes.Buffer
cmd.Stdout = &out
if err := cmd.Run(); err != nil {
return nil, err
}
return out.Bytes(), nil
}
func SendMedia(ctx *hc.Ctx, data []byte, mime, caption string) {
switch {
case strings.HasPrefix(mime, "video/mp4"):