From dadf23a40cfa2eff2e5caa5c1edd24a6b550e95a Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Sun, 28 May 2023 19:20:25 +0200 Subject: use llog instead of fmt debugging --- spotify.go | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'spotify.go') diff --git a/spotify.go b/spotify.go index d075930..e2499e5 100644 --- a/spotify.go +++ b/spotify.go @@ -9,7 +9,6 @@ package main import ( "errors" - "fmt" "os" "strings" @@ -68,17 +67,15 @@ func (_ *SpotifyBackend) OnSongFinished(*Song) {} func (spotify *SpotifyBackend) Play(song *Song, player *Player) { trackID := song.Uri session := spotify.session - fmt.Println("Loading track for play: ", trackID) + llog.Debug("Loading track for play: %v", trackID) // Get the track metadata: it holds information about which files and encodings are available track, err := session.Mercury().GetTrack(utils.Base62ToHex(trackID)) if err != nil { - fmt.Println("Error loading track: ", err) + llog.Error("Error loading track: %s", err) return } - fmt.Println("Track:", track.GetName()) - // For now, select the OGG 160kbps variant of the track. The "high quality" // setting in the official Spotify app is the OGG 320kbps variant. var selectedFile *Spotify.AudioFile @@ -102,26 +99,26 @@ func (spotify *SpotifyBackend) Search(keyword string) []Song { resp, err := session.Mercury().Search(keyword, 12, session.Country(), session.Username()) if err != nil { - fmt.Println("Failed to search:", err) + llog.Error("Failed to search: %s", err) return []Song{} } res := resp.Results - fmt.Println("Search results for ", keyword) - fmt.Println("=============================") + llog.DDebug("Search results for %s", keyword) + llog.DDebug("=============================") if res.Error != nil { - fmt.Println("Search result error:", res.Error) + llog.Error("Search result error: %s", res.Error) } - fmt.Printf("\nTracks: %d (total %d)\n", len(res.Tracks.Hits), res.Tracks.Total) + llog.Debug("\nTracks: %d (total %d)\n", len(res.Tracks.Hits), res.Tracks.Total) results := []Song{} for _, track := range res.Tracks.Hits { uriParts := strings.Split(track.Uri, ":") - results = append(results, NewSong(track.Name, track.Artists[0].Name, "spotify", uriParts[len(uriParts)-1])) - // fmt.Printf(" => %v (%s)\n", track, track.Uri) + results = append(results, NewSong(track.Name, track.Artists[0].Name, + "spotify", uriParts[len(uriParts)-1])) } return results -- cgit v1.2.3