Fixing issue downloading songs
This commit is contained in:
parent
83c0857f43
commit
4955a806fa
4
test.go
4
test.go
|
@ -71,9 +71,9 @@ func (t TestSettings) testYoutubeSong() {
|
|||
for url, title := range songs {
|
||||
err := add(dummyUser, url)
|
||||
if err != nil {
|
||||
fmt.Printf("For: %s; Expected: %s; Got: %s", url, title, err.Error())
|
||||
fmt.Printf("For: %s; Expected: %s; Got: %s\n", url, title, err.Error())
|
||||
} else if dj.queue.CurrentSong().Title() != title {
|
||||
fmt.Printf("For: %s; Expected: %s; Got: %s", url, title, dj.queue.CurrentSong().Title())
|
||||
fmt.Printf("For: %s; Expected: %s; Got: %s\n", url, title, dj.queue.CurrentSong().Title())
|
||||
}
|
||||
|
||||
time.Sleep(time.Second * 5)
|
||||
|
|
|
@ -40,15 +40,17 @@ func (dl *YouTubeDLSong) Download() error {
|
|||
// Checks to see if song is already downloaded
|
||||
if _, err := os.Stat(fmt.Sprintf("%s/.mumbledj/songs/%s", dj.homeDir, dl.Filename())); os.IsNotExist(err) {
|
||||
cmd := exec.Command("youtube-dl", "--output", fmt.Sprintf(`~/.mumbledj/songs/%s`, dl.Filename()), "--format", "m4a", dl.url)
|
||||
if err := cmd.Run(); err == nil {
|
||||
err = cmd.Run()
|
||||
if err == nil {
|
||||
if dj.conf.Cache.Enabled {
|
||||
dj.cache.CheckMaximumDirectorySize()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
} else {
|
||||
Verbose("youtube-dl: " + err.Error())
|
||||
return errors.New("Song download failed.")
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue