aboutsummaryrefslogtreecommitdiffstats
path: root/src/scrobbler.rs
diff options
context:
space:
mode:
authorsalmonik <raisersoft@proton.me>2026-05-18 21:46:26 +0200
committersalmonik <raisersoft@proton.me>2026-05-18 21:46:26 +0200
commit6cceb3cbfacb6f4416e49321a9b63b4ce7a9f036 (patch)
tree9d883ada0e6cfb4fd533635885dfb4459f200128 /src/scrobbler.rs
parentfirst public release. (diff)
downloadrsplayer-6cceb3cbfacb6f4416e49321a9b63b4ce7a9f036.tar.gz
rsplayer-6cceb3cbfacb6f4416e49321a9b63b4ce7a9f036.zip
fix for new symphony API and less debug info in release
Diffstat (limited to '')
-rw-r--r--src/scrobbler.rs72
1 files changed, 44 insertions, 28 deletions
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 {
47 .send()?; 47 .send()?;
48 48
49 if !resp.status().is_success() { 49 if !resp.status().is_success() {
50 eprintln!( 50 crate::debug_eprintln(format_args!(
51 "scrobble: listenbrainz token validation failed: {}", 51 "scrobble: listenbrainz token validation failed: {}",
52 resp.status() 52 resp.status()
53 ); 53 ));
54 return Ok(None); 54 return Ok(None);
55 } 55 }
56 56
@@ -62,13 +62,18 @@ impl Scrobbler {
62 .and_then(|v| v.as_str()) 62 .and_then(|v| v.as_str())
63 .map(|s| s.to_string()); 63 .map(|s| s.to_string());
64 if let Some(ref u) = user { 64 if let Some(ref u) = user {
65 eprintln!("scrobble: listenbrainz token valid (user: {})", u); 65 crate::debug_eprintln(format_args!(
66 "scrobble: listenbrainz token valid (user: {})",
67 u
68 ));
66 } else { 69 } else {
67 eprintln!("scrobble: listenbrainz token valid"); 70 crate::debug_eprintln(format_args!("scrobble: listenbrainz token valid"));
68 } 71 }
69 Ok(user) 72 Ok(user)
70 } else { 73 } else {
71 eprintln!("scrobble: listenbrainz token invalid — scrobbling will fail"); 74 crate::debug_eprintln(format_args!(
75 "scrobble: listenbrainz token invalid — scrobbling will fail"
76 ));
72 Ok(None) 77 Ok(None)
73 } 78 }
74 } 79 }
@@ -82,22 +87,29 @@ impl Scrobbler {
82 && !secret.is_empty() 87 && !secret.is_empty()
83 && !session_key.is_empty() 88 && !session_key.is_empty()
84 { 89 {
85 eprintln!("scrobble: now_playing -> lastfm '{} - {}'", artist, track); 90 crate::debug_eprintln(format_args!(
91 "scrobble: now_playing -> lastfm '{} - {}'",
92 artist, track
93 ));
86 let _ = 94 let _ =
87 self.send_lastfm_now_playing(api_key, secret, session_key, artist, track, album); 95 self.send_lastfm_now_playing(api_key, secret, session_key, artist, track, album);
88 } else { 96 } else {
89 eprintln!("scrobble: now_playing -> lastfm skipped (no credentials)"); 97 crate::debug_eprintln(format_args!(
98 "scrobble: now_playing -> lastfm skipped (no credentials)"
99 ));
90 } 100 }
91 if let Some(token) = &self.listenbrainz_token 101 if let Some(token) = &self.listenbrainz_token
92 && !token.is_empty() 102 && !token.is_empty()
93 { 103 {
94 eprintln!( 104 crate::debug_eprintln(format_args!(
95 "scrobble: now_playing -> listenbrainz '{} - {}'", 105 "scrobble: now_playing -> listenbrainz '{} - {}'",
96 artist, track 106 artist, track
97 ); 107 ));
98 let _ = self.send_listenbrainz_now_playing(token, artist, track, album); 108 let _ = self.send_listenbrainz_now_playing(token, artist, track, album);
99 } else { 109 } else {
100 eprintln!("scrobble: now_playing -> listenbrainz skipped (no token)"); 110 crate::debug_eprintln(format_args!(
111 "scrobble: now_playing -> listenbrainz skipped (no token)"
112 ));
101 } 113 }
102 } 114 }
103 115
@@ -110,10 +122,10 @@ impl Scrobbler {
110 && !secret.is_empty() 122 && !secret.is_empty()
111 && !session_key.is_empty() 123 && !session_key.is_empty()
112 { 124 {
113 eprintln!( 125 crate::debug_eprintln(format_args!(
114 "scrobble: scrobble -> lastfm '{} - {}' (ts={})", 126 "scrobble: scrobble -> lastfm '{} - {}' (ts={})",
115 artist, track, timestamp 127 artist, track, timestamp
116 ); 128 ));
117 let _ = self.send_lastfm_scrobble( 129 let _ = self.send_lastfm_scrobble(
118 api_key, 130 api_key,
119 secret, 131 secret,
@@ -124,18 +136,22 @@ impl Scrobbler {
124 timestamp, 136 timestamp,
125 ); 137 );
126 } else { 138 } else {
127 eprintln!("scrobble: scrobble -> lastfm skipped (no credentials)"); 139 crate::debug_eprintln(format_args!(
140 "scrobble: scrobble -> lastfm skipped (no credentials)"
141 ));
128 } 142 }
129 if let Some(token) = &self.listenbrainz_token 143 if let Some(token) = &self.listenbrainz_token
130 && !token.is_empty() 144 && !token.is_empty()
131 { 145 {
132 eprintln!( 146 crate::debug_eprintln(format_args!(
133 "scrobble: scrobble -> listenbrainz '{} - {}' (ts={})", 147 "scrobble: scrobble -> listenbrainz '{} - {}' (ts={})",
134 artist, track, timestamp 148 artist, track, timestamp
135 ); 149 ));
136 let _ = self.send_listenbrainz_scrobble(token, artist, track, album, timestamp); 150 let _ = self.send_listenbrainz_scrobble(token, artist, track, album, timestamp);
137 } else { 151 } else {
138 eprintln!("scrobble: scrobble -> listenbrainz skipped (no token)"); 152 crate::debug_eprintln(format_args!(
153 "scrobble: scrobble -> listenbrainz skipped (no token)"
154 ));
139 } 155 }
140 } 156 }
141 157
@@ -177,13 +193,13 @@ impl Scrobbler {
177 193
178 let resp = self.client.post(LASTFM_API_URL).form(&params).send()?; 194 let resp = self.client.post(LASTFM_API_URL).form(&params).send()?;
179 if resp.status().is_success() { 195 if resp.status().is_success() {
180 eprintln!("scrobble: lastfm now_playing ok"); 196 crate::debug_eprintln(format_args!("scrobble: lastfm now_playing ok"));
181 } else { 197 } else {
182 eprintln!( 198 crate::debug_eprintln(format_args!(
183 "scrobble: lastfm now_playing error: {} {}", 199 "scrobble: lastfm now_playing error: {} {}",
184 resp.status(), 200 resp.status(),
185 resp.text().unwrap_or_default() 201 resp.text().unwrap_or_default()
186 ); 202 ));
187 } 203 }
188 Ok(()) 204 Ok(())
189 } 205 }
@@ -217,13 +233,13 @@ impl Scrobbler {
217 233
218 let resp = self.client.post(LASTFM_API_URL).form(&params).send()?; 234 let resp = self.client.post(LASTFM_API_URL).form(&params).send()?;
219 if resp.status().is_success() { 235 if resp.status().is_success() {
220 eprintln!("scrobble: lastfm scrobble ok"); 236 crate::debug_eprintln(format_args!("scrobble: lastfm scrobble ok"));
221 } else { 237 } else {
222 eprintln!( 238 crate::debug_eprintln(format_args!(
223 "scrobble: lastfm scrobble error: {} {}", 239 "scrobble: lastfm scrobble error: {} {}",
224 resp.status(), 240 resp.status(),
225 resp.text().unwrap_or_default() 241 resp.text().unwrap_or_default()
226 ); 242 ));
227 } 243 }
228 Ok(()) 244 Ok(())
229 } 245 }
@@ -257,13 +273,13 @@ impl Scrobbler {
257 .json(&payload) 273 .json(&payload)
258 .send()?; 274 .send()?;
259 if resp.status().is_success() { 275 if resp.status().is_success() {
260 eprintln!("scrobble: listenbrainz now_playing ok"); 276 crate::debug_eprintln(format_args!("scrobble: listenbrainz now_playing ok"));
261 } else { 277 } else {
262 eprintln!( 278 crate::debug_eprintln(format_args!(
263 "scrobble: listenbrainz now_playing error: {} {}", 279 "scrobble: listenbrainz now_playing error: {} {}",
264 resp.status(), 280 resp.status(),
265 resp.text().unwrap_or_default() 281 resp.text().unwrap_or_default()
266 ); 282 ));
267 } 283 }
268 Ok(()) 284 Ok(())
269 } 285 }
@@ -299,13 +315,13 @@ impl Scrobbler {
299 .json(&payload) 315 .json(&payload)
300 .send()?; 316 .send()?;
301 if resp.status().is_success() { 317 if resp.status().is_success() {
302 eprintln!("scrobble: listenbrainz scrobble ok"); 318 crate::debug_eprintln(format_args!("scrobble: listenbrainz scrobble ok"));
303 } else { 319 } else {
304 eprintln!( 320 crate::debug_eprintln(format_args!(
305 "scrobble: listenbrainz scrobble error: {} {}", 321 "scrobble: listenbrainz scrobble error: {} {}",
306 resp.status(), 322 resp.status(),
307 resp.text().unwrap_or_default() 323 resp.text().unwrap_or_default()
308 ); 324 ));
309 } 325 }
310 Ok(()) 326 Ok(())
311 } 327 }