Getting soundcloud to work [ci skip]

This commit is contained in:
MichaelOultram 2015-08-13 14:33:37 +01:00
parent 9d29d77dfa
commit 67c8b696a4
3 changed files with 7 additions and 4 deletions

View file

@ -103,6 +103,7 @@ func (sc SoundCloud) NewSong(user *gumble.User, trackData *jsonq.JsonQuery, play
thumbnail: thumbnail, thumbnail: thumbnail,
submitter: user, submitter: user,
duration: string(duration), duration: string(duration),
format: "mp3",
playlist: playlist, playlist: playlist,
skippers: make([]string, 0), skippers: make([]string, 0),
dontSkip: false, dontSkip: false,

View file

@ -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), offset: int((offsetDays * 86400) + (offsetHours * 3600) + (offsetMinutes * 60) + offsetSeconds),
duration: durationString, duration: durationString,
thumbnail: thumbnail, thumbnail: thumbnail,
format: "m4a",
skippers: make([]string, 0), skippers: make([]string, 0),
playlist: playlist, playlist: playlist,
dontSkip: false, dontSkip: false,

View file

@ -20,6 +20,7 @@ type YouTubeDLSong struct {
duration string duration string
url string url string
offset int offset int
format string
playlist Playlist playlist Playlist
skippers []string skippers []string
dontSkip bool dontSkip bool
@ -40,7 +41,7 @@ func (dl *YouTubeDLSong) Download() error {
// Checks to see if song is already downloaded // 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) { 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() output, err := cmd.CombinedOutput()
if err == nil { if err == nil {
if dj.conf.Cache.Enabled { if dj.conf.Cache.Enabled {
@ -48,9 +49,9 @@ func (dl *YouTubeDLSong) Download() error {
} }
return nil return nil
} else { } else {
args := "youtube-dl " args := ""
for s := range cmd.Args { for s := range cmd.Args {
args += cmd.Args[s] args += cmd.Args[s] + " "
} }
Verbose(args) Verbose(args)
Verbose(string(output)) Verbose(string(output))
@ -153,7 +154,7 @@ func (dl *YouTubeDLSong) ID() string {
// Filename returns the filename of the Song. // Filename returns the filename of the Song.
func (dl *YouTubeDLSong) Filename() string { func (dl *YouTubeDLSong) Filename() string {
return dl.id + ".m4a" return dl.id + dl.format
} }
// Duration returns the duration of the Song. // Duration returns the duration of the Song.