yt-dlp output fix
This commit is contained in:
parent
846b5a2123
commit
cdcb0f8c06
104
main.go
104
main.go
@ -211,8 +211,9 @@ func downloadVideo(url string) error {
|
|||||||
"yt-dlp",
|
"yt-dlp",
|
||||||
"-i",
|
"-i",
|
||||||
"-q",
|
"-q",
|
||||||
|
"-f", "bestaudio",
|
||||||
"-o",
|
"-o",
|
||||||
"vid",
|
"vid.%(ext)s",
|
||||||
url)
|
url)
|
||||||
|
|
||||||
err := cmd.Run()
|
err := cmd.Run()
|
||||||
@ -220,104 +221,3 @@ func downloadVideo(url string) error {
|
|||||||
|
|
||||||
return err
|
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")
|
|
||||||
// }
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user