mirror of
https://github.com/riwiwa/muzi.git
synced 2026-04-20 11:25:51 -07:00
fix now-playing status on listenbrainz endpoint and add config support
This commit is contained in:
@@ -119,7 +119,8 @@ func (h *LastFMHandler) handleHandshake(w http.ResponseWriter, r *http.Request)
|
||||
return
|
||||
}
|
||||
|
||||
w.Write([]byte(fmt.Sprintf("OK\n%s\nhttp://127.0.0.1:1234/2.0/\nhttp://127.0.0.1:1234/2.0/\n", sessionKey)))
|
||||
baseURL := getBaseURL(r)
|
||||
w.Write([]byte(fmt.Sprintf("OK\n%s\n%s/2.0/\n%s/2.0/\n", sessionKey, baseURL, baseURL)))
|
||||
}
|
||||
|
||||
func (h *LastFMHandler) handleGetToken(w http.ResponseWriter, apiKey string) {
|
||||
|
||||
@@ -200,6 +200,10 @@ func GetNowPlaying(userId int) (NowPlaying, bool) {
|
||||
if ok && np.SongName != "" {
|
||||
return np, true
|
||||
}
|
||||
np, ok = platforms["listenbrainz"]
|
||||
if ok && np.SongName != "" {
|
||||
return np, true
|
||||
}
|
||||
return NowPlaying{}, false
|
||||
}
|
||||
|
||||
|
||||
@@ -401,11 +401,7 @@ func getBaseURL(r *http.Request) string {
|
||||
if r.TLS != nil {
|
||||
scheme = "https"
|
||||
}
|
||||
host := r.Host
|
||||
if host == "localhost:1234" || host == "localhost" {
|
||||
host = "127.0.0.1:1234"
|
||||
}
|
||||
return scheme + "://" + host
|
||||
return scheme + "://" + r.Host
|
||||
}
|
||||
|
||||
func GetSpotifyAuthURL(userId int, baseURL string) (string, error) {
|
||||
|
||||
Reference in New Issue
Block a user