fix now-playing status on listenbrainz endpoint and add config support

This commit is contained in:
2026-02-28 16:08:46 -08:00
parent a2ffbbdce4
commit 7542eaf321
10 changed files with 103 additions and 22 deletions

View File

@@ -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) {

View File

@@ -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
}

View File

@@ -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) {