From 72cfdea882dc92c98c026b30d3883ae597010452 Mon Sep 17 00:00:00 2001 From: Trond A Ekseth Date: Sat, 19 Nov 2022 18:05:02 +0100 Subject: [PATCH] Add config for ytdl name/path --- events.go | 5 ++--- ytdl/ytdl.go => ytdl.go | 8 +++++--- 2 files changed, 7 insertions(+), 6 deletions(-) rename ytdl/ytdl.go => ytdl.go (87%) diff --git a/events.go b/events.go index c89fd24..5b35414 100644 --- a/events.go +++ b/events.go @@ -4,7 +4,6 @@ import ( "context" "dndmusicbot/ffmpeg" discordspeaker "dndmusicbot/speaker" - "dndmusicbot/ytdl" "encoding/json" "fmt" "log" @@ -163,7 +162,7 @@ func (app *App) ambianceAdd(payload ...interface{}) { return } - err := ytdl.DownloadAmbiance(amburl, ambtitle) + err := DownloadAmbiance(amburl, ambtitle) if err != nil { log.Println(err) return @@ -384,7 +383,7 @@ func (app *App) loadPlaylist(payload ...interface{}) { } _, yt, err := app.cache.GetOrCreateBytes(vid+".txt", func() ([]byte, error) { - uri, err := ytdl.NewYTdl(vid) + uri, err := NewYTdl(vid) if err != nil { return nil, err } diff --git a/ytdl/ytdl.go b/ytdl.go similarity index 87% rename from ytdl/ytdl.go rename to ytdl.go index be555b9..74e915f 100644 --- a/ytdl/ytdl.go +++ b/ytdl.go @@ -1,4 +1,4 @@ -package ytdl +package main import ( "fmt" @@ -9,8 +9,9 @@ import ( var yturl = "https://youtu.be/%s" func NewYTdl(vid string) ([]byte, error) { + ytdl := config.GetString("youtube.ytdl") uri, err := exec.Command( - "./bin/yt-dlp_linux", + ytdl, fmt.Sprintf(yturl, vid), "--cookies", "./cookies.txt", "--no-call-home", @@ -29,8 +30,9 @@ func NewYTdl(vid string) ([]byte, error) { } func DownloadAmbiance(uri string, name string) error { + ytdl := config.GetString("youtube.ytdl") err := exec.Command( - "./bin/yt-dlp_linux", + ytdl, uri, "-x", "--audio-format", "mp3",