From cdcb0f8c06357db5181177c6253c4d43db27ee66 Mon Sep 17 00:00:00 2001 From: Javier Feliz Date: Tue, 4 Feb 2025 23:53:19 -0500 Subject: [PATCH] yt-dlp output fix --- main.go | 106 ++------------------------------------------------------ 1 file changed, 3 insertions(+), 103 deletions(-) diff --git a/main.go b/main.go index 51811b5..edf4800 100644 --- a/main.go +++ b/main.go @@ -211,113 +211,13 @@ func downloadVideo(url string) error { "yt-dlp", "-i", "-q", + "-f", "bestaudio", "-o", - "vid", + "vid.%(ext)s", url) err := cmd.Run() log.Println("Downloaded") return err -} - -// func handleCommand(s *dg.Session, msg *dg.MessageCreate) { -// // Ignore any message sent by the bot itself -// if msg.Author.ID == s.State.User.ID { -// return -// } - -// if !strings.HasPrefix(msg.Content, commandPrefix) { -// return -// } - -// // Get the channel -// msgChannel, err := s.State.Channel(msg.ChannelID) -// if err != nil { -// log.Println("Could not find the channel the message came from") -// return -// } - -// msgServer, err := s.State.Guild(msgChannel.GuildID) -// if err != nil { -// log.Println("Failed to get server for message") -// } - -// var voiceChannelId string -// for _, vs := range msgServer.VoiceStates { -// if vs.UserID == msg.Author.ID { -// voiceChannelId = vs.ChannelID -// } -// } - -// voiceChannel, err := s.ChannelVoiceJoin(msgServer.ID, voiceChannelId, false, true) -// if err != nil { -// log.Println("Failed to join voice channel") -// } - -// log.Println("Joined channel") - -// log.Println("Starting ffmpeg stream") -// // I got the original implementation from: -// // https://github.com/nhooyr/botatouille/blob/7e1cd9d5a8d517fd43fd11599b2a62bf832a5c96/cmd/botatouille/music/music.go#L62-L104 -// // after hours of searching. -// ffmpeg := exec.Command( -// "ffmpeg", -// "-i", "testfile.wav", -// "-hide_banner", -// "-loglevel", "quiet", -// "-i", "testfile.wav", -// "-f", "data", -// "-map", "0:a", -// "-ar", "48k", -// "-ac", "2", -// "-acodec", "libopus", -// "-b:a", "128k", -// "pipe:1") - -// ffmpegOut, err := ffmpeg.StdoutPipe() -// if err != nil { -// log.Fatal(err) -// } - -// // runtime.LockOSThread() -// err = ffmpeg.Start() -// if err != nil { -// log.Fatal(err) -// } - -// packets := [][]byte{} - -// for { -// // I read in the RFC that frames will not be bigger than this size -// p := make([]byte, 960) -// n, err := ffmpegOut.Read(p) -// if err != nil { -// log.Printf("Bytes: %d", n) -// if err == io.EOF { -// log.Println("Done streaming") -// break -// } -// log.Fatal(err) -// } - -// // log.Printf("Read packet: %d bytes", n) -// packets = append(packets, p[:n]) -// } - -// voiceChannel.Speaking(true) -// time.Sleep(time.Second * 2) -// log.Println("Playing sound") - -// for _, p := range packets { -// log.Printf("Sending packet: %d bytes", len(p)) -// voiceChannel.OpusSend <- p -// } - -// voiceChannel.Speaking(false) -// log.Println("Disconnecting from voice channel") -// time.Sleep(time.Second * 2) - -// voiceChannel.Disconnect() -// log.Println("Disconnected") -// } +} \ No newline at end of file