Fixing build errors
This commit is contained in:
parent
974a52df7e
commit
5e70e69222
58
web.go
58
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))
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Reference in a new issue