Skip to content

Commit 407e13b

Browse files
unhappychoiceclaude
andcommitted
feat(fetcher): add lastfm_top_tracks
Sibling of `lastfm_top_artists`: a user's top tracks for a rolling window via `user.getTopTracks`. Same option contract (`user` / `period` / `limit`) and same 10 shapes via the shared `lastfm/top.rs` surface. Difference from `top_artists` lives in the row mapping: the API nests the artist as a proper `{"name": "..."}` object (rather than the `{"#text": "..."}` form `user.getRecentTracks` uses), so each row's secondary label populates from `artist.name`. Empty strings collapse to `None` so a malformed response renders the track without a stray trailing dash. Rendering helpers receive `secondary = Some(artist)` and emit `"Track — Artist"` titles automatically — no per-sibling rewrite of the row format. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
1 parent 9d8dd2b commit 407e13b

2 files changed

Lines changed: 451 additions & 0 deletions

File tree

‎src/fetcher/lastfm/mod.rs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ mod common;
1414
mod scrobbles_today;
1515
mod top;
1616
mod top_artists;
17+
mod top_tracks;
1718

1819
use std::sync::Arc;
1920

@@ -23,6 +24,7 @@ pub fn fetchers() -> Vec<Arc<dyn Fetcher>> {
2324
vec![
2425
Arc::new(scrobbles_today::LastfmScrobblesToday),
2526
Arc::new(top_artists::LastfmTopArtists),
27+
Arc::new(top_tracks::LastfmTopTracks),
2628
]
2729
}
2830

@@ -41,5 +43,6 @@ mod tests {
4143
}
4244
assert!(names.contains(&"lastfm_scrobbles_today".to_string()));
4345
assert!(names.contains(&"lastfm_top_artists".to_string()));
46+
assert!(names.contains(&"lastfm_top_tracks".to_string()));
4447
}
4548
}

0 commit comments

Comments
 (0)