From 4955a806fa65b845f63c847add299b9c55ca9d05 Mon Sep 17 00:00:00 2001 From: MichaelOultram Date: Wed, 12 Aug 2015 22:18:22 +0100 Subject: [PATCH] Fixing issue downloading songs --- test.go | 4 ++-- youtube_dl.go | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/test.go b/test.go index d56813e..fcc1857 100644 --- a/test.go +++ b/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) diff --git a/youtube_dl.go b/youtube_dl.go index a661df4..3d6b8ad 100644 --- a/youtube_dl.go +++ b/youtube_dl.go @@ -40,14 +40,16 @@ 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.") } - Verbose("youtube-dl: " + err.Error()) - return errors.New("Song download failed.") } return nil }