aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorsalmonik <raisersoft@proton.me>2026-05-16 11:43:32 +0200
committersalmonik <raisersoft@proton.me>2026-05-16 11:43:32 +0200
commit04add15691578316ff3da5b5a07d05b314488370 (patch)
tree458b1066001697faa75466d51c7dfd9008ccac16 /tests
parentaesthetic changes (diff)
downloadrsplayer-04add15691578316ff3da5b5a07d05b314488370.tar.gz
rsplayer-04add15691578316ff3da5b5a07d05b314488370.zip
Add scrobbling support (Last.fm + ListenBrainz) and rsp settings reload
- Full Last.fm API implementation with MD5 signing (track.updateNowPlaying, track.scrobble) - Full ListenBrainz API implementation (/1/submit-listens for playing_now and single) - ScrobbleState in daemon tracking track, start time, and unix timestamp per play - Scrobble threshold: ≥30s play AND (≥half duration OR ≥4 min) - Duration extraction from symphonia codec params into AudioMetadata and Track - Token validation at daemon startup and on config change - ListenBrainz token valid (user: Salmonium) command to re-read config from disk (avoids token in shell history) - Desktop notifications for token validation results - Empty-credential filtering (empty string = no-op)
Diffstat (limited to 'tests')
-rw-r--r--tests/queue.rs2
-rw-r--r--tests/scrobbler.rs48
2 files changed, 25 insertions, 25 deletions
diff --git a/tests/queue.rs b/tests/queue.rs
index a73c312..ccc6e54 100644
--- a/tests/queue.rs
+++ b/tests/queue.rs
@@ -7,6 +7,7 @@ fn track(path: &str, title: Option<&str>, artist: Option<&str>, album: Option<&s
7 title: title.map(|s| s.to_string()), 7 title: title.map(|s| s.to_string()),
8 artist: artist.map(|s| s.to_string()), 8 artist: artist.map(|s| s.to_string()),
9 album: album.map(|s| s.to_string()), 9 album: album.map(|s| s.to_string()),
10 duration_secs: None,
10 } 11 }
11} 12}
12 13
@@ -16,6 +17,7 @@ fn track_no_meta(path: &str) -> Track {
16 title: None, 17 title: None,
17 artist: None, 18 artist: None,
18 album: None, 19 album: None,
20 duration_secs: None,
19 } 21 }
20} 22}
21 23
diff --git a/tests/scrobbler.rs b/tests/scrobbler.rs
index f326250..5453748 100644
--- a/tests/scrobbler.rs
+++ b/tests/scrobbler.rs
@@ -24,54 +24,52 @@ fn test_scrobbler_new_with_none() {
24} 24}
25 25
26#[test] 26#[test]
27fn test_scrobbler_now_playing_no_api_key() { 27fn test_scrobbler_now_playing_no_creds() {
28 let scrobbler = Scrobbler::new(None, None, None, None); 28 let scrobbler = Scrobbler::new(None, None, None, None);
29 scrobbler.now_playing("Artist", "Track", Some("Album")); 29 scrobbler.now_playing("Artist", "Track", Some("Album"));
30} 30}
31 31
32#[test] 32#[test]
33fn test_scrobbler_now_playing_with_api_key() { 33fn test_scrobbler_now_playing_partial_lastfm() {
34 // Only api_key set — not enough to trigger Last.fm (needs secret + session_key too)
34 let scrobbler = Scrobbler::new(Some("api_key".to_string()), None, None, None); 35 let scrobbler = Scrobbler::new(Some("api_key".to_string()), None, None, None);
35 scrobbler.now_playing("Artist", "Track", Some("Album")); 36 scrobbler.now_playing("Artist", "Track", Some("Album"));
36} 37}
37 38
38#[test] 39#[test]
39fn test_scrobbler_scrobble_no_keys() { 40fn test_scrobbler_now_playing_no_album() {
40 let scrobbler = Scrobbler::new(None, None, None, None);
41 scrobbler.scrobble("Artist", "Track", Some("Album"), 1234567890);
42}
43
44#[test]
45fn test_scrobbler_scrobble_with_lastfm() {
46 let scrobbler = Scrobbler::new(Some("api_key".to_string()), None, None, None); 41 let scrobbler = Scrobbler::new(Some("api_key".to_string()), None, None, None);
47 scrobbler.scrobble("Artist", "Track", Some("Album"), 1234567890); 42 scrobbler.now_playing("Artist", "Track", None);
48} 43}
49 44
50#[test] 45#[test]
51fn test_scrobbler_scrobble_with_listenbrainz() { 46fn test_scrobbler_scrobble_no_creds() {
52 let scrobbler = Scrobbler::new(None, None, None, Some("token".to_string())); 47 let scrobbler = Scrobbler::new(None, None, None, None);
53 scrobbler.scrobble("Artist", "Track", Some("Album"), 1234567890); 48 scrobbler.scrobble("Artist", "Track", Some("Album"), 1234567890);
54} 49}
55 50
56#[test] 51#[test]
57fn test_scrobbler_scrobble_with_both() { 52fn test_scrobbler_scrobble_no_album() {
58 let scrobbler = Scrobbler::new( 53 let scrobbler = Scrobbler::new(None, None, None, None);
59 Some("api_key".to_string()), 54 scrobbler.scrobble("Artist", "Track", None, 1234567890);
60 None,
61 None,
62 Some("token".to_string()),
63 );
64 scrobbler.scrobble("Artist", "Track", Some("Album"), 1234567890);
65} 55}
66 56
67#[test] 57#[test]
68fn test_scrobbler_now_playing_no_album() { 58fn test_scrobbler_scrobble_partial_lastfm() {
59 // Only api_key set — not enough to trigger Last.fm
69 let scrobbler = Scrobbler::new(Some("api_key".to_string()), None, None, None); 60 let scrobbler = Scrobbler::new(Some("api_key".to_string()), None, None, None);
70 scrobbler.now_playing("Artist", "Track", None); 61 scrobbler.scrobble("Artist", "Track", Some("Album"), 1234567890);
71} 62}
72 63
73#[test] 64#[test]
74fn test_scrobbler_scrobble_no_album() { 65fn test_scrobbler_skip_empty_credentials() {
75 let scrobbler = Scrobbler::new(Some("api_key".to_string()), None, None, None); 66 // Empty strings should be treated as unset — no HTTP requests
76 scrobbler.scrobble("Artist", "Track", None, 1234567890); 67 let scrobbler = Scrobbler::new(
68 Some("".to_string()),
69 Some("".to_string()),
70 Some("".to_string()),
71 Some("".to_string()),
72 );
73 scrobbler.now_playing("Artist", "Track", Some("Album"));
74 scrobbler.scrobble("Artist", "Track", Some("Album"), 1234567890);
77} 75}