Skip to content

Commit 3520dc7

Browse files
revert: remove unused lastfm agent types and methods from main
Revert lastfm additions from d9a37c9 that are unused on main. These types and methods belong on the genius-playlist feature branch where they will be wired up. Fixes clippy dead_code errors in CI. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 26c1905 commit 3520dc7

File tree

2 files changed

+0
-306
lines changed

2 files changed

+0
-306
lines changed

crates/mt-tauri/src/lastfm/client.rs

Lines changed: 0 additions & 224 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,6 @@ impl LastFmClient {
2424
}
2525
}
2626

27-
#[cfg(test)]
28-
pub(crate) fn new_unconfigured() -> Self {
29-
Self {
30-
config: ApiKeyConfig {
31-
api_key: None,
32-
api_secret: None,
33-
},
34-
rate_limiter: Arc::new(RateLimiter::new()),
35-
http_client: reqwest::Client::new(),
36-
base_url: "https://ws.audioscrobbler.com/2.0/".to_string(),
37-
}
38-
}
39-
4027
/// Check if API is properly configured
4128
pub(crate) fn is_configured(&self) -> bool {
4229
self.config.is_configured()
@@ -333,106 +320,6 @@ impl LastFmClient {
333320

334321
Ok(scrobble_response.scrobbles.attr.accepted)
335322
}
336-
337-
pub(crate) async fn get_similar_tracks(
338-
&self,
339-
artist: &str,
340-
track: &str,
341-
limit: u32,
342-
) -> Result<Vec<SimilarTrack>, LastFmError> {
343-
let mut params = BTreeMap::new();
344-
params.insert("artist".to_string(), artist.to_string());
345-
params.insert("track".to_string(), track.to_string());
346-
params.insert("limit".to_string(), limit.to_string());
347-
params.insert("autocorrect".to_string(), "1".to_string());
348-
349-
let response = self
350-
.api_call("track.getSimilar", params, None, false)
351-
.await?;
352-
353-
let parsed: SimilarTracksResponse =
354-
serde_json::from_value(response).map_err(|e| LastFmError::ParseError(e.to_string()))?;
355-
356-
Ok(parsed.similartracks.track)
357-
}
358-
359-
pub(crate) async fn get_similar_artists(
360-
&self,
361-
artist: &str,
362-
limit: u32,
363-
) -> Result<Vec<SimilarArtist>, LastFmError> {
364-
let mut params = BTreeMap::new();
365-
params.insert("artist".to_string(), artist.to_string());
366-
params.insert("limit".to_string(), limit.to_string());
367-
params.insert("autocorrect".to_string(), "1".to_string());
368-
369-
let response = self
370-
.api_call("artist.getSimilar", params, None, false)
371-
.await?;
372-
373-
let parsed: SimilarArtistsResponse =
374-
serde_json::from_value(response).map_err(|e| LastFmError::ParseError(e.to_string()))?;
375-
376-
Ok(parsed.similarartists.artist)
377-
}
378-
379-
pub(crate) async fn get_track_top_tags(
380-
&self,
381-
artist: &str,
382-
track: &str,
383-
) -> Result<Vec<TagInfo>, LastFmError> {
384-
let mut params = BTreeMap::new();
385-
params.insert("artist".to_string(), artist.to_string());
386-
params.insert("track".to_string(), track.to_string());
387-
params.insert("autocorrect".to_string(), "1".to_string());
388-
389-
let response = self
390-
.api_call("track.getTopTags", params, None, false)
391-
.await?;
392-
393-
let parsed: TopTagsResponse =
394-
serde_json::from_value(response).map_err(|e| LastFmError::ParseError(e.to_string()))?;
395-
396-
Ok(parsed.toptags.tag)
397-
}
398-
399-
pub(crate) async fn get_top_artists_by_tag(
400-
&self,
401-
tag: &str,
402-
limit: u32,
403-
) -> Result<Vec<TagArtist>, LastFmError> {
404-
let mut params = BTreeMap::new();
405-
params.insert("tag".to_string(), tag.to_string());
406-
params.insert("limit".to_string(), limit.to_string());
407-
408-
let response = self
409-
.api_call("tag.getTopArtists", params, None, false)
410-
.await?;
411-
412-
let parsed: TagTopArtistsResponse =
413-
serde_json::from_value(response).map_err(|e| LastFmError::ParseError(e.to_string()))?;
414-
415-
Ok(parsed.topartists.artist)
416-
}
417-
418-
pub(crate) async fn get_top_tracks_by_country(
419-
&self,
420-
country: &str,
421-
limit: u32,
422-
) -> Result<Vec<GeoTrack>, LastFmError> {
423-
let mut params = BTreeMap::new();
424-
params.insert("country".to_string(), country.to_string());
425-
params.insert("limit".to_string(), limit.to_string());
426-
427-
let response = self
428-
.api_call("geo.getTopTracks", params, None, false)
429-
.await?;
430-
431-
let parsed: GeoTopTracksResponse =
432-
serde_json::from_value(response).map_err(|e| LastFmError::ParseError(e.to_string()))?;
433-
434-
Ok(parsed.tracks.track)
435-
}
436323
}
437324

438325
impl Default for LastFmClient {
@@ -567,115 +454,4 @@ mod tests {
567454
assert!(matches!(result, Err(LastFmError::NotConfigured)));
568455
}
569456
}
570-
571-
#[test]
572-
fn test_parse_similar_tracks_response() {
573-
let json: serde_json::Value = serde_json::from_str(
574-
r#"{
575-
"similartracks": {
576-
"track": [
577-
{"name": "Track A", "artist": {"name": "Artist A"}, "match": "0.95"},
578-
{"name": "Track B", "artist": {"name": "Artist B"}, "match": "0.80"}
579-
]
580-
}
581-
}"#,
582-
)
583-
.unwrap();
584-
585-
let parsed: SimilarTracksResponse = serde_json::from_value(json).unwrap();
586-
assert_eq!(parsed.similartracks.track.len(), 2);
587-
assert_eq!(parsed.similartracks.track[0].name, "Track A");
588-
assert_eq!(parsed.similartracks.track[0].artist.name(), "Artist A");
589-
assert_eq!(
590-
parsed.similartracks.track[0].match_score.as_deref(),
591-
Some("0.95")
592-
);
593-
}
594-
595-
#[test]
596-
fn test_parse_similar_artists_response() {
597-
let json: serde_json::Value = serde_json::from_str(
598-
r#"{
599-
"similarartists": {
600-
"artist": [
601-
{"name": "Artist X", "match": "0.90"},
602-
{"name": "Artist Y", "match": "0.75"}
603-
]
604-
}
605-
}"#,
606-
)
607-
.unwrap();
608-
609-
let parsed: SimilarArtistsResponse = serde_json::from_value(json).unwrap();
610-
assert_eq!(parsed.similarartists.artist.len(), 2);
611-
assert_eq!(parsed.similarartists.artist[0].name, "Artist X");
612-
}
613-
614-
#[test]
615-
fn test_parse_top_tags_response() {
616-
let json: serde_json::Value = serde_json::from_str(
617-
r#"{
618-
"toptags": {
619-
"tag": [
620-
{"name": "rock", "count": 100},
621-
{"name": "alternative", "count": 80}
622-
]
623-
}
624-
}"#,
625-
)
626-
.unwrap();
627-
628-
let parsed: TopTagsResponse = serde_json::from_value(json).unwrap();
629-
assert_eq!(parsed.toptags.tag.len(), 2);
630-
assert_eq!(parsed.toptags.tag[0].name, "rock");
631-
assert_eq!(parsed.toptags.tag[0].count, Some(100));
632-
}
633-
634-
#[test]
635-
fn test_parse_tag_top_artists_response() {
636-
let json: serde_json::Value = serde_json::from_str(
637-
r#"{
638-
"topartists": {
639-
"artist": [
640-
{"name": "Radiohead"},
641-
{"name": "Muse"}
642-
]
643-
}
644-
}"#,
645-
)
646-
.unwrap();
647-
648-
let parsed: TagTopArtistsResponse = serde_json::from_value(json).unwrap();
649-
assert_eq!(parsed.topartists.artist.len(), 2);
650-
assert_eq!(parsed.topartists.artist[0].name, "Radiohead");
651-
}
652-
653-
#[test]
654-
fn test_parse_geo_top_tracks_response() {
655-
let json: serde_json::Value = serde_json::from_str(
656-
r#"{
657-
"tracks": {
658-
"track": [
659-
{"name": "Bohemian Rhapsody", "artist": {"name": "Queen"}},
660-
{"name": "Imagine", "artist": {"name": "John Lennon"}}
661-
]
662-
}
663-
}"#,
664-
)
665-
.unwrap();
666-
667-
let parsed: GeoTopTracksResponse = serde_json::from_value(json).unwrap();
668-
assert_eq!(parsed.tracks.track.len(), 2);
669-
assert_eq!(parsed.tracks.track[0].name, "Bohemian Rhapsody");
670-
assert_eq!(parsed.tracks.track[0].artist.name(), "Queen");
671-
}
672-
673-
#[test]
674-
fn test_parse_similar_tracks_empty() {
675-
let json: serde_json::Value =
676-
serde_json::from_str(r#"{"similartracks": {"track": []}}"#).unwrap();
677-
678-
let parsed: SimilarTracksResponse = serde_json::from_value(json).unwrap();
679-
assert!(parsed.similartracks.track.is_empty());
680-
}
681457
}

crates/mt-tauri/src/lastfm/types.rs

Lines changed: 0 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -252,88 +252,6 @@ pub struct NowPlayingApiResponse {
252252
pub nowplaying: HashMap<String, serde_json::Value>,
253253
}
254254

255-
#[derive(Debug, Clone, Serialize, Deserialize)]
256-
pub struct SimilarTracksResponse {
257-
pub similartracks: SimilarTracksContainer,
258-
}
259-
260-
#[derive(Debug, Clone, Serialize, Deserialize)]
261-
pub struct SimilarTracksContainer {
262-
pub track: Vec<SimilarTrack>,
263-
}
264-
265-
#[derive(Debug, Clone, Serialize, Deserialize)]
266-
pub struct SimilarTrack {
267-
pub name: String,
268-
pub artist: ArtistInfo,
269-
#[serde(rename = "match")]
270-
pub match_score: Option<String>,
271-
}
272-
273-
#[derive(Debug, Clone, Serialize, Deserialize)]
274-
pub struct SimilarArtistsResponse {
275-
pub similarartists: SimilarArtistsContainer,
276-
}
277-
278-
#[derive(Debug, Clone, Serialize, Deserialize)]
279-
pub struct SimilarArtistsContainer {
280-
pub artist: Vec<SimilarArtist>,
281-
}
282-
283-
#[derive(Debug, Clone, Serialize, Deserialize)]
284-
pub struct SimilarArtist {
285-
pub name: String,
286-
#[serde(rename = "match")]
287-
pub match_score: Option<String>,
288-
}
289-
290-
#[derive(Debug, Clone, Serialize, Deserialize)]
291-
pub struct TopTagsResponse {
292-
pub toptags: TopTagsContainer,
293-
}
294-
295-
#[derive(Debug, Clone, Serialize, Deserialize)]
296-
pub struct TopTagsContainer {
297-
pub tag: Vec<TagInfo>,
298-
}
299-
300-
#[derive(Debug, Clone, Serialize, Deserialize)]
301-
pub struct TagInfo {
302-
pub name: String,
303-
pub count: Option<u32>,
304-
}
305-
306-
#[derive(Debug, Clone, Serialize, Deserialize)]
307-
pub struct TagTopArtistsResponse {
308-
pub topartists: TagTopArtistsContainer,
309-
}
310-
311-
#[derive(Debug, Clone, Serialize, Deserialize)]
312-
pub struct TagTopArtistsContainer {
313-
pub artist: Vec<TagArtist>,
314-
}
315-
316-
#[derive(Debug, Clone, Serialize, Deserialize)]
317-
pub struct TagArtist {
318-
pub name: String,
319-
}
320-
321-
#[derive(Debug, Clone, Serialize, Deserialize)]
322-
pub struct GeoTopTracksResponse {
323-
pub tracks: GeoTopTracksContainer,
324-
}
325-
326-
#[derive(Debug, Clone, Serialize, Deserialize)]
327-
pub struct GeoTopTracksContainer {
328-
pub track: Vec<GeoTrack>,
329-
}
330-
331-
#[derive(Debug, Clone, Serialize, Deserialize)]
332-
pub struct GeoTrack {
333-
pub name: String,
334-
pub artist: ArtistInfo,
335-
}
336-
337255
#[cfg(test)]
338256
mod tests {
339257
use super::*;

0 commit comments

Comments
 (0)