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/daemon.rs | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) (limited to 'src/daemon.rs') diff --git a/src/daemon.rs b/src/daemon.rs index 59fc3d8..8b74357 100644 --- a/src/daemon.rs +++ b/src/daemon.rs @@ -33,10 +33,10 @@ impl ScrobbleState { .as_secs(); let title = track.title.clone().unwrap_or_default(); let artist = track.artist.clone().unwrap_or_default(); - eprintln!( + crate::debug_eprintln(format_args!( "scrobble: tracking start for '{} - {}' (ts={})", artist, title, ts - ); + )); self.track = Some(track); self.start_time = Some(Instant::now()); self.timestamp = Some(ts); @@ -44,7 +44,9 @@ impl ScrobbleState { fn should_scrobble(&self) -> bool { let (Some(track), Some(start)) = (&self.track, self.start_time) else { - eprintln!("scrobble: should_scrobble false — no track or start_time"); + crate::debug_eprintln(format_args!( + "scrobble: should_scrobble false — no track or start_time" + )); return false; }; let elapsed = start.elapsed().as_secs(); @@ -54,10 +56,10 @@ impl ScrobbleState { .map(|d| (d / 2.0) as u64) .unwrap_or(u64::MAX) .min(240); - eprintln!( + crate::debug_eprintln(format_args!( "scrobble: should_scrobble {} (elapsed={}s threshold={}s duration={:?})", result, elapsed, threshold, track.duration_secs - ); + )); result } @@ -158,10 +160,10 @@ fn try_scrobble_current(scrobbler: &RwLock, state: &mut ScrobbleState let artist = track.artist.as_deref().unwrap_or("(unknown artist)"); let title = track.title.as_deref().unwrap_or("(unknown title)"); let album = track.album.as_deref(); - eprintln!( + crate::debug_eprintln(format_args!( "scrobble: sending scrobble for '{} - {}' at ts={}", artist, title, ts - ); + )); if let Ok(s) = scrobbler.read() { s.scrobble(artist, title, album, ts); } @@ -171,10 +173,10 @@ fn try_scrobble_current(scrobbler: &RwLock, state: &mut ScrobbleState .as_ref() .and_then(|t| t.title.as_deref()) .unwrap_or("(no track)"); - eprintln!( + crate::debug_eprintln(format_args!( "scrobble: skipping scrobble for '{}' — not enough play time", title - ); + )); } state.clear(); } @@ -183,7 +185,10 @@ fn send_now_playing(scrobbler: &RwLock, track: &Track) { let artist = track.artist.as_deref().unwrap_or("(unknown artist)"); let title = track.title.as_deref().unwrap_or("(unknown title)"); let album = track.album.as_deref(); - eprintln!("scrobble: sending now_playing for '{} - {}'", artist, title); + crate::debug_eprintln(format_args!( + "scrobble: sending now_playing for '{} - {}'", + artist, title + )); if let Ok(s) = scrobbler.read() { s.now_playing(artist, title, album); } @@ -260,9 +265,17 @@ pub fn start_daemon() -> Result<(), Box> { && let Ok(s) = scrobbler.read() { match s.validate_listenbrainz_token() { - Ok(Some(user)) => eprintln!("scrobble: listenbrainz token valid (user: {})", user), - Ok(None) => eprintln!("scrobble: listenbrainz token invalid, scrobbling disabled"), - Err(e) => eprintln!("scrobble: listenbrainz validation error: {}", e), + Ok(Some(user)) => crate::debug_eprintln(format_args!( + "scrobble: listenbrainz token valid (user: {})", + user + )), + Ok(None) => crate::debug_eprintln(format_args!( + "scrobble: listenbrainz token invalid, scrobbling disabled" + )), + Err(e) => crate::debug_eprintln(format_args!( + "scrobble: listenbrainz validation error: {}", + e + )), } } let scrobble_state = Arc::new(Mutex::new(ScrobbleState::new())); -- cgit v1.2.3