From 67c8b696a4bbf0f9cced8233f28470d243fb7170 Mon Sep 17 00:00:00 2001 From: MichaelOultram Date: Thu, 13 Aug 2015 14:33:37 +0100 Subject: [PATCH] Getting soundcloud to work [ci skip] --- service_soundcloud.go | 1 + service_youtube.go | 1 + youtube_dl.go | 9 +++++---- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/service_soundcloud.go b/service_soundcloud.go index 2f80980..ba36ccc 100644 --- a/service_soundcloud.go +++ b/service_soundcloud.go @@ -103,6 +103,7 @@ func (sc SoundCloud) NewSong(user *gumble.User, trackData *jsonq.JsonQuery, play thumbnail: thumbnail, submitter: user, duration: string(duration), + format: "mp3", playlist: playlist, skippers: make([]string, 0), dontSkip: false, diff --git a/service_youtube.go b/service_youtube.go index 08dc01a..1cac086 100644 --- a/service_youtube.go +++ b/service_youtube.go @@ -169,6 +169,7 @@ func (yt YouTube) NewSong(user *gumble.User, id, offset string, playlist Playlis offset: int((offsetDays * 86400) + (offsetHours * 3600) + (offsetMinutes * 60) + offsetSeconds), duration: durationString, thumbnail: thumbnail, + format: "m4a", skippers: make([]string, 0), playlist: playlist, dontSkip: false, diff --git a/youtube_dl.go b/youtube_dl.go index b9053b9..abb294e 100644 --- a/youtube_dl.go +++ b/youtube_dl.go @@ -20,6 +20,7 @@ type YouTubeDLSong struct { duration string url string offset int + format string playlist Playlist skippers []string dontSkip bool @@ -40,7 +41,7 @@ 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", "--no-mtime", "--output", fmt.Sprintf("%s/.mumbledj/songs/%s", dj.homeDir, dl.Filename()), "--format", "m4a", "--prefer-ffmpeg", dl.url) + cmd := exec.Command("youtube-dl", "--no-mtime", "--output", fmt.Sprintf("%s/.mumbledj/songs/%s", dj.homeDir, dl.Filename()), "--format", dl.format, "--prefer-ffmpeg", dl.url) output, err := cmd.CombinedOutput() if err == nil { if dj.conf.Cache.Enabled { @@ -48,9 +49,9 @@ func (dl *YouTubeDLSong) Download() error { } return nil } else { - args := "youtube-dl " + args := "" for s := range cmd.Args { - args += cmd.Args[s] + args += cmd.Args[s] + " " } Verbose(args) Verbose(string(output)) @@ -153,7 +154,7 @@ func (dl *YouTubeDLSong) ID() string { // Filename returns the filename of the Song. func (dl *YouTubeDLSong) Filename() string { - return dl.id + ".m4a" + return dl.id + dl.format } // Duration returns the duration of the Song.