Fixing issue downloading songs

This commit is contained in:
MichaelOultram 2015-08-12 22:18:22 +01:00
parent 83c0857f43
commit 4955a806fa
2 changed files with 7 additions and 5 deletions

View file

@ -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)

View file

@ -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
}