Add config for ytdl name/path

pull/3/head
Trond Ekseth 2022-11-19 18:05:02 +01:00
parent e79f5aee67
commit 72cfdea882
2 changed files with 7 additions and 6 deletions

View File

@ -4,7 +4,6 @@ import (
"context" "context"
"dndmusicbot/ffmpeg" "dndmusicbot/ffmpeg"
discordspeaker "dndmusicbot/speaker" discordspeaker "dndmusicbot/speaker"
"dndmusicbot/ytdl"
"encoding/json" "encoding/json"
"fmt" "fmt"
"log" "log"
@ -163,7 +162,7 @@ func (app *App) ambianceAdd(payload ...interface{}) {
return return
} }
err := ytdl.DownloadAmbiance(amburl, ambtitle) err := DownloadAmbiance(amburl, ambtitle)
if err != nil { if err != nil {
log.Println(err) log.Println(err)
return return
@ -384,7 +383,7 @@ func (app *App) loadPlaylist(payload ...interface{}) {
} }
_, yt, err := app.cache.GetOrCreateBytes(vid+".txt", func() ([]byte, error) { _, yt, err := app.cache.GetOrCreateBytes(vid+".txt", func() ([]byte, error) {
uri, err := ytdl.NewYTdl(vid) uri, err := NewYTdl(vid)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -1,4 +1,4 @@
package ytdl package main
import ( import (
"fmt" "fmt"
@ -9,8 +9,9 @@ import (
var yturl = "https://youtu.be/%s" var yturl = "https://youtu.be/%s"
func NewYTdl(vid string) ([]byte, error) { func NewYTdl(vid string) ([]byte, error) {
ytdl := config.GetString("youtube.ytdl")
uri, err := exec.Command( uri, err := exec.Command(
"./bin/yt-dlp_linux", ytdl,
fmt.Sprintf(yturl, vid), fmt.Sprintf(yturl, vid),
"--cookies", "./cookies.txt", "--cookies", "./cookies.txt",
"--no-call-home", "--no-call-home",
@ -29,8 +30,9 @@ func NewYTdl(vid string) ([]byte, error) {
} }
func DownloadAmbiance(uri string, name string) error { func DownloadAmbiance(uri string, name string) error {
ytdl := config.GetString("youtube.ytdl")
err := exec.Command( err := exec.Command(
"./bin/yt-dlp_linux", ytdl,
uri, uri,
"-x", "-x",
"--audio-format", "mp3", "--audio-format", "mp3",