diff --git a/web.go b/web.go index c87eff6..b59ff7f 100644 --- a/web.go +++ b/web.go @@ -59,7 +59,7 @@ func (web *WebServer) makeWeb() { http.HandleFunc("/api/add", web.add) http.HandleFunc("/api/volume", web.volume) http.HandleFunc("/api/skip", web.skip) - http.HandleFunc("/api/status", web.status) + //http.HandleFunc("/api/status", web.status) http.ListenAndServe(":"+strconv.Itoa(web.port), nil) } @@ -125,34 +125,34 @@ func (web *WebServer) skip(w http.ResponseWriter, r *http.Request) { } } -func (web *WebServer) status(w http.ResponseWriter, r *http.Request) { - var uname = web.token_client[r.FormValue("token")] - if uname == nil { - str, ok := json.Marshal(&Status{true, "Invalid Token"}).(string) - fmt.Fprintf(w, str) - } else { - // Generate song queue - queueLength := dj.queue.Len() - var songsInQueue [queueLength]SongInfo - for i := 0; i < dj.queue.Len(); i++ { - songItem := dj.queue.Get(i) - songsInQueue[i] = &SongInfo{ - TitleID: songItem.ID(), - Title: songItem.Title(), - Submitter: songItem.Submitter(), - Duration: songItem.Duration(), - Thumbnail: songItem.Thumbnail(), - } - if !isNil(songItem.Playlist()) { - songsInQueue[i].PlaylistID = songItem.Playlist().ID() - songsInQueue[i].Playlist = songItem.Playlist().Title() - } - } - - // Output status - fmt.Fprintf(w, string(json.MarshalIndent(&Status{false, "", songsInQueue}))) - } -} +//func (web *WebServer) status(w http.ResponseWriter, r *http.Request) { +// var uname = web.token_client[r.FormValue("token")] +// if uname == nil { +// str, ok := json.Marshal(&Status{true, "Invalid Token"}).(string) +// fmt.Fprintf(w, str) +// } else { +// // Generate song queue +// queueLength := dj.queue.Len() +// var songsInQueue [queueLength]SongInfo +// for i := 0; i < dj.queue.Len(); i++ { +// songItem := dj.queue.Get(i) +// songsInQueue[i] = &SongInfo{ +// TitleID: songItem.ID(), +// Title: songItem.Title(), +// Submitter: songItem.Submitter(), +// Duration: songItem.Duration(), +// Thumbnail: songItem.Thumbnail(), +// } +// if !isNil(songItem.Playlist()) { +// songsInQueue[i].PlaylistID = songItem.Playlist().ID() +// songsInQueue[i].Playlist = songItem.Playlist().Title() +// } +// } +// +// // Output status +// fmt.Fprintf(w, string(json.MarshalIndent(&Status{false, "", songsInQueue}))) +// } +//} func (website *WebServer) GetWebAddress(user *gumble.User) { Verbose("Port number: " + strconv.Itoa(web.port)) diff --git a/youtube_dl.go b/youtube_dl.go index 6484f95..df4e963 100644 --- a/youtube_dl.go +++ b/youtube_dl.go @@ -26,8 +26,8 @@ type YouTubeDL struct { func (dl *YouTubeDL) Download() error { // Checks to see if song is already downloaded - if _, err := os.Stat(fmt.Sprintf("%s/.mumbledj/songs/%s", dj.homeDir, id+".m4a")); os.IsNotExist(err) { - cmd := exec.Command("youtube-dl", "--output", fmt.Sprintf(`~/.mumbledj/songs/%s`, id+".m4a"), "--format", "m4a", "--", url) + if _, err := os.Stat(fmt.Sprintf("%s/.mumbledj/songs/%s", dj.homeDir, dl.id+".m4a")); os.IsNotExist(err) { + cmd := exec.Command("youtube-dl", "--output", fmt.Sprintf(`~/.mumbledj/songs/%s`, dl.id+".m4a"), "--format", "m4a", "--", dl.url) if err := cmd.Run(); err == nil { if dj.conf.Cache.Enabled { dj.cache.CheckMaximumDirectorySize() @@ -42,7 +42,7 @@ func (dl *YouTubeDL) Download() error { // Play plays the song. Once the song is playing, a notification is displayed in a text message that features the song // thumbnail, URL, title, duration, and submitter. func (dl *YouTubeDL) Play() { - if s.offset != 0 { + if dl.offset != 0 { offsetDuration, _ := time.ParseDuration(fmt.Sprintf("%ds", dl.offset)) dj.audioStream.Offset = offsetDuration }