feat: enhance YouTube download functionality with chunked requests and audio conversion
This commit is contained in:
@@ -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"):
|
||||
|
||||
Reference in New Issue
Block a user