From 6cceb3cbfacb6f4416e49321a9b63b4ce7a9f036 Mon Sep 17 00:00:00 2001 From: salmonik Date: Mon, 18 May 2026 21:46:26 +0200 Subject: fix for new symphony API and less debug info in release --- src/scrobbler.rs | 72 ++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 44 insertions(+), 28 deletions(-) (limited to 'src/scrobbler.rs') diff --git a/src/scrobbler.rs b/src/scrobbler.rs index 2e79933..93cb3c2 100644 --- a/src/scrobbler.rs +++ b/src/scrobbler.rs @@ -47,10 +47,10 @@ impl Scrobbler { .send()?; if !resp.status().is_success() { - eprintln!( + crate::debug_eprintln(format_args!( "scrobble: listenbrainz token validation failed: {}", resp.status() - ); + )); return Ok(None); } @@ -62,13 +62,18 @@ impl Scrobbler { .and_then(|v| v.as_str()) .map(|s| s.to_string()); if let Some(ref u) = user { - eprintln!("scrobble: listenbrainz token valid (user: {})", u); + crate::debug_eprintln(format_args!( + "scrobble: listenbrainz token valid (user: {})", + u + )); } else { - eprintln!("scrobble: listenbrainz token valid"); + crate::debug_eprintln(format_args!("scrobble: listenbrainz token valid")); } Ok(user) } else { - eprintln!("scrobble: listenbrainz token invalid — scrobbling will fail"); + crate::debug_eprintln(format_args!( + "scrobble: listenbrainz token invalid — scrobbling will fail" + )); Ok(None) } } @@ -82,22 +87,29 @@ impl Scrobbler { && !secret.is_empty() && !session_key.is_empty() { - eprintln!("scrobble: now_playing -> lastfm '{} - {}'", artist, track); + crate::debug_eprintln(format_args!( + "scrobble: now_playing -> lastfm '{} - {}'", + artist, track + )); let _ = self.send_lastfm_now_playing(api_key, secret, session_key, artist, track, album); } else { - eprintln!("scrobble: now_playing -> lastfm skipped (no credentials)"); + crate::debug_eprintln(format_args!( + "scrobble: now_playing -> lastfm skipped (no credentials)" + )); } if let Some(token) = &self.listenbrainz_token && !token.is_empty() { - eprintln!( + crate::debug_eprintln(format_args!( "scrobble: now_playing -> listenbrainz '{} - {}'", artist, track - ); + )); let _ = self.send_listenbrainz_now_playing(token, artist, track, album); } else { - eprintln!("scrobble: now_playing -> listenbrainz skipped (no token)"); + crate::debug_eprintln(format_args!( + "scrobble: now_playing -> listenbrainz skipped (no token)" + )); } } @@ -110,10 +122,10 @@ impl Scrobbler { && !secret.is_empty() && !session_key.is_empty() { - eprintln!( + crate::debug_eprintln(format_args!( "scrobble: scrobble -> lastfm '{} - {}' (ts={})", artist, track, timestamp - ); + )); let _ = self.send_lastfm_scrobble( api_key, secret, @@ -124,18 +136,22 @@ impl Scrobbler { timestamp, ); } else { - eprintln!("scrobble: scrobble -> lastfm skipped (no credentials)"); + crate::debug_eprintln(format_args!( + "scrobble: scrobble -> lastfm skipped (no credentials)" + )); } if let Some(token) = &self.listenbrainz_token && !token.is_empty() { - eprintln!( + crate::debug_eprintln(format_args!( "scrobble: scrobble -> listenbrainz '{} - {}' (ts={})", artist, track, timestamp - ); + )); let _ = self.send_listenbrainz_scrobble(token, artist, track, album, timestamp); } else { - eprintln!("scrobble: scrobble -> listenbrainz skipped (no token)"); + crate::debug_eprintln(format_args!( + "scrobble: scrobble -> listenbrainz skipped (no token)" + )); } } @@ -177,13 +193,13 @@ impl Scrobbler { let resp = self.client.post(LASTFM_API_URL).form(¶ms).send()?; if resp.status().is_success() { - eprintln!("scrobble: lastfm now_playing ok"); + crate::debug_eprintln(format_args!("scrobble: lastfm now_playing ok")); } else { - eprintln!( + crate::debug_eprintln(format_args!( "scrobble: lastfm now_playing error: {} {}", resp.status(), resp.text().unwrap_or_default() - ); + )); } Ok(()) } @@ -217,13 +233,13 @@ impl Scrobbler { let resp = self.client.post(LASTFM_API_URL).form(¶ms).send()?; if resp.status().is_success() { - eprintln!("scrobble: lastfm scrobble ok"); + crate::debug_eprintln(format_args!("scrobble: lastfm scrobble ok")); } else { - eprintln!( + crate::debug_eprintln(format_args!( "scrobble: lastfm scrobble error: {} {}", resp.status(), resp.text().unwrap_or_default() - ); + )); } Ok(()) } @@ -257,13 +273,13 @@ impl Scrobbler { .json(&payload) .send()?; if resp.status().is_success() { - eprintln!("scrobble: listenbrainz now_playing ok"); + crate::debug_eprintln(format_args!("scrobble: listenbrainz now_playing ok")); } else { - eprintln!( + crate::debug_eprintln(format_args!( "scrobble: listenbrainz now_playing error: {} {}", resp.status(), resp.text().unwrap_or_default() - ); + )); } Ok(()) } @@ -299,13 +315,13 @@ impl Scrobbler { .json(&payload) .send()?; if resp.status().is_success() { - eprintln!("scrobble: listenbrainz scrobble ok"); + crate::debug_eprintln(format_args!("scrobble: listenbrainz scrobble ok")); } else { - eprintln!( + crate::debug_eprintln(format_args!( "scrobble: listenbrainz scrobble error: {} {}", resp.status(), resp.text().unwrap_or_default() - ); + )); } Ok(()) } -- cgit v1.2.3